rev 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. data/README +45 -9
  2. data/doc/rdoc/classes/Rev.html +368 -0
  3. data/doc/rdoc/classes/Rev.src/M000001.html +28 -0
  4. data/doc/rdoc/classes/Rev.src/M000002.html +35 -0
  5. data/doc/rdoc/classes/Rev.src/M000003.html +24 -0
  6. data/doc/rdoc/classes/Rev.src/M000004.html +28 -0
  7. data/doc/rdoc/classes/Rev.src/M000005.html +27 -0
  8. data/doc/rdoc/classes/Rev.src/M000006.html +33 -0
  9. data/doc/rdoc/classes/Rev.src/M000007.html +43 -0
  10. data/doc/rdoc/classes/Rev.src/M000008.html +16 -0
  11. data/doc/rdoc/classes/Rev/Buffer.html +354 -0
  12. data/doc/rdoc/classes/Rev/Buffer.src/M000019.html +17 -0
  13. data/doc/rdoc/classes/Rev/Buffer.src/M000020.html +29 -0
  14. data/doc/rdoc/classes/Rev/Buffer.src/M000021.html +27 -0
  15. data/doc/rdoc/classes/Rev/Buffer.src/M000022.html +27 -0
  16. data/doc/rdoc/classes/Rev/Buffer.src/M000023.html +31 -0
  17. data/doc/rdoc/classes/Rev/Buffer.src/M000024.html +31 -0
  18. data/doc/rdoc/classes/Rev/Buffer.src/M000025.html +30 -0
  19. data/doc/rdoc/classes/Rev/Buffer.src/M000026.html +50 -0
  20. data/doc/rdoc/classes/Rev/Buffer.src/M000027.html +22 -0
  21. data/doc/rdoc/classes/Rev/Buffer.src/M000028.html +24 -0
  22. data/doc/rdoc/classes/Rev/Buffer.src/M000029.html +24 -0
  23. data/doc/rdoc/classes/Rev/BufferedIO.html +397 -0
  24. data/doc/rdoc/classes/Rev/BufferedIO.src/M000095.html +23 -0
  25. data/doc/rdoc/classes/Rev/BufferedIO.src/M000096.html +16 -0
  26. data/doc/rdoc/classes/Rev/BufferedIO.src/M000097.html +16 -0
  27. data/doc/rdoc/classes/Rev/BufferedIO.src/M000098.html +16 -0
  28. data/doc/rdoc/classes/Rev/BufferedIO.src/M000099.html +18 -0
  29. data/doc/rdoc/classes/Rev/BufferedIO.src/M000100.html +18 -0
  30. data/doc/rdoc/classes/Rev/BufferedIO.src/M000101.html +23 -0
  31. data/doc/rdoc/classes/Rev/BufferedIO.src/M000102.html +18 -0
  32. data/doc/rdoc/classes/Rev/BufferedIO.src/M000103.html +20 -0
  33. data/doc/rdoc/classes/Rev/BufferedIO.src/M000104.html +24 -0
  34. data/doc/rdoc/classes/Rev/BufferedIO.src/M000105.html +23 -0
  35. data/doc/rdoc/classes/Rev/BufferedIO.src/M000106.html +22 -0
  36. data/doc/rdoc/classes/Rev/BufferedIO.src/M000107.html +29 -0
  37. data/doc/rdoc/classes/Rev/BufferedIO/Writer.html +154 -0
  38. data/doc/rdoc/classes/Rev/BufferedIO/Writer.src/M000108.html +19 -0
  39. data/doc/rdoc/classes/Rev/BufferedIO/Writer.src/M000109.html +18 -0
  40. data/doc/rdoc/classes/Rev/DNSResolver.html +401 -0
  41. data/doc/rdoc/classes/Rev/DNSResolver.src/M000124.html +25 -0
  42. data/doc/rdoc/classes/Rev/DNSResolver.src/M000125.html +29 -0
  43. data/doc/rdoc/classes/Rev/DNSResolver.src/M000126.html +20 -0
  44. data/doc/rdoc/classes/Rev/DNSResolver.src/M000127.html +19 -0
  45. data/doc/rdoc/classes/Rev/DNSResolver.src/M000128.html +16 -0
  46. data/doc/rdoc/classes/Rev/DNSResolver.src/M000129.html +16 -0
  47. data/doc/rdoc/classes/Rev/DNSResolver.src/M000131.html +19 -0
  48. data/doc/rdoc/classes/Rev/DNSResolver.src/M000132.html +21 -0
  49. data/doc/rdoc/classes/Rev/DNSResolver.src/M000133.html +27 -0
  50. data/doc/rdoc/classes/Rev/DNSResolver.src/M000134.html +28 -0
  51. data/doc/rdoc/classes/Rev/DNSResolver.src/M000135.html +55 -0
  52. data/doc/rdoc/classes/Rev/DNSResolver/Timeout.html +154 -0
  53. data/doc/rdoc/classes/Rev/DNSResolver/Timeout.src/M000136.html +20 -0
  54. data/doc/rdoc/classes/Rev/DNSResolver/Timeout.src/M000137.html +22 -0
  55. data/doc/rdoc/classes/Rev/HttpChunkHeader.html +156 -0
  56. data/doc/rdoc/classes/Rev/HttpChunkHeader.src/M000031.html +19 -0
  57. data/doc/rdoc/classes/Rev/HttpClient.html +460 -0
  58. data/doc/rdoc/classes/Rev/HttpClient.src/M000042.html +18 -0
  59. data/doc/rdoc/classes/Rev/HttpClient.src/M000043.html +27 -0
  60. data/doc/rdoc/classes/Rev/HttpClient.src/M000044.html +24 -0
  61. data/doc/rdoc/classes/Rev/HttpClient.src/M000045.html +19 -0
  62. data/doc/rdoc/classes/Rev/HttpClient.src/M000046.html +17 -0
  63. data/doc/rdoc/classes/Rev/HttpClient.src/M000047.html +19 -0
  64. data/doc/rdoc/classes/Rev/HttpClient.src/M000048.html +18 -0
  65. data/doc/rdoc/classes/Rev/HttpClient.src/M000049.html +18 -0
  66. data/doc/rdoc/classes/Rev/HttpClient.src/M000050.html +19 -0
  67. data/doc/rdoc/classes/Rev/HttpClient.src/M000051.html +19 -0
  68. data/doc/rdoc/classes/Rev/HttpClient.src/M000052.html +19 -0
  69. data/doc/rdoc/classes/Rev/HttpClient.src/M000053.html +41 -0
  70. data/doc/rdoc/classes/Rev/HttpClient.src/M000054.html +18 -0
  71. data/doc/rdoc/classes/Rev/HttpClient.src/M000055.html +34 -0
  72. data/doc/rdoc/classes/Rev/HttpEncoding.html +310 -0
  73. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000009.html +20 -0
  74. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000010.html +20 -0
  75. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000011.html +18 -0
  76. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000012.html +18 -0
  77. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000013.html +18 -0
  78. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000014.html +19 -0
  79. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000015.html +18 -0
  80. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000016.html +18 -0
  81. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000017.html +22 -0
  82. data/doc/rdoc/classes/Rev/HttpEncoding.src/M000018.html +18 -0
  83. data/doc/rdoc/classes/Rev/HttpResponseHeader.html +219 -0
  84. data/doc/rdoc/classes/Rev/HttpResponseHeader.src/M000032.html +18 -0
  85. data/doc/rdoc/classes/Rev/HttpResponseHeader.src/M000033.html +18 -0
  86. data/doc/rdoc/classes/Rev/HttpResponseHeader.src/M000034.html +18 -0
  87. data/doc/rdoc/classes/Rev/IOWatcher.html +285 -0
  88. data/doc/rdoc/classes/Rev/IOWatcher.src/M000079.html +17 -0
  89. data/doc/rdoc/classes/Rev/IOWatcher.src/M000080.html +27 -0
  90. data/doc/rdoc/classes/Rev/IOWatcher.src/M000081.html +26 -0
  91. data/doc/rdoc/classes/Rev/IOWatcher.src/M000082.html +27 -0
  92. data/doc/rdoc/classes/Rev/IOWatcher.src/M000083.html +27 -0
  93. data/doc/rdoc/classes/Rev/IOWatcher.src/M000084.html +24 -0
  94. data/doc/rdoc/classes/Rev/IOWatcher.src/M000085.html +25 -0
  95. data/doc/rdoc/classes/Rev/Listener.html +207 -0
  96. data/doc/rdoc/classes/Rev/Listener.src/M000065.html +19 -0
  97. data/doc/rdoc/classes/Rev/Listener.src/M000066.html +19 -0
  98. data/doc/rdoc/classes/Rev/Listener.src/M000067.html +16 -0
  99. data/doc/rdoc/classes/Rev/Listener.src/M000068.html +18 -0
  100. data/doc/rdoc/classes/Rev/Loop.html +395 -0
  101. data/doc/rdoc/classes/Rev/Loop.src/M000070.html +25 -0
  102. data/doc/rdoc/classes/Rev/Loop.src/M000071.html +45 -0
  103. data/doc/rdoc/classes/Rev/Loop.src/M000072.html +18 -0
  104. data/doc/rdoc/classes/Rev/Loop.src/M000073.html +23 -0
  105. data/doc/rdoc/classes/Rev/Loop.src/M000074.html +19 -0
  106. data/doc/rdoc/classes/Rev/Loop.src/M000075.html +17 -0
  107. data/doc/rdoc/classes/Rev/Loop.src/M000076.html +27 -0
  108. data/doc/rdoc/classes/Rev/Loop.src/M000077.html +32 -0
  109. data/doc/rdoc/classes/Rev/Loop.src/M000078.html +32 -0
  110. data/doc/rdoc/classes/Rev/Server.html +164 -0
  111. data/doc/rdoc/classes/Rev/Server.src/M000121.html +32 -0
  112. data/doc/rdoc/classes/Rev/Server.src/M000122.html +20 -0
  113. data/doc/rdoc/classes/Rev/Socket.html +213 -0
  114. data/doc/rdoc/classes/Rev/Socket.src/M000035.html +21 -0
  115. data/doc/rdoc/classes/Rev/Socket.src/M000036.html +25 -0
  116. data/doc/rdoc/classes/Rev/Socket.src/M000037.html +16 -0
  117. data/doc/rdoc/classes/Rev/Socket.src/M000038.html +16 -0
  118. data/doc/rdoc/classes/Rev/Socket/Connector.html +154 -0
  119. data/doc/rdoc/classes/Rev/Socket/Connector.src/M000040.html +19 -0
  120. data/doc/rdoc/classes/Rev/Socket/Connector.src/M000041.html +28 -0
  121. data/doc/rdoc/classes/Rev/TCPListener.html +161 -0
  122. data/doc/rdoc/classes/Rev/TCPListener.src/M000069.html +23 -0
  123. data/doc/rdoc/classes/Rev/TCPServer.html +147 -0
  124. data/doc/rdoc/classes/Rev/TCPServer.src/M000123.html +20 -0
  125. data/doc/rdoc/classes/Rev/TCPSocket.html +233 -0
  126. data/doc/rdoc/classes/Rev/TCPSocket.src/M000056.html +20 -0
  127. data/doc/rdoc/classes/Rev/TCPSocket.src/M000057.html +34 -0
  128. data/doc/rdoc/classes/Rev/TCPSocket.src/M000058.html +24 -0
  129. data/doc/rdoc/classes/Rev/TCPSocket.src/M000059.html +18 -0
  130. data/doc/rdoc/classes/Rev/TCPSocket/TCPConnectResolver.html +171 -0
  131. data/doc/rdoc/classes/Rev/TCPSocket/TCPConnectResolver.src/M000060.html +19 -0
  132. data/doc/rdoc/classes/Rev/TCPSocket/TCPConnectResolver.src/M000061.html +27 -0
  133. data/doc/rdoc/classes/Rev/TCPSocket/TCPConnectResolver.src/M000062.html +23 -0
  134. data/doc/rdoc/classes/Rev/TCPSocket/TCPConnectSocket.html +154 -0
  135. data/doc/rdoc/classes/Rev/TCPSocket/TCPConnectSocket.src/M000063.html +25 -0
  136. data/doc/rdoc/classes/Rev/TCPSocket/TCPConnectSocket.src/M000064.html +23 -0
  137. data/doc/rdoc/classes/Rev/TimerWatcher.html +288 -0
  138. data/doc/rdoc/classes/Rev/TimerWatcher.src/M000086.html +17 -0
  139. data/doc/rdoc/classes/Rev/TimerWatcher.src/M000087.html +27 -0
  140. data/doc/rdoc/classes/Rev/TimerWatcher.src/M000088.html +26 -0
  141. data/doc/rdoc/classes/Rev/TimerWatcher.src/M000089.html +27 -0
  142. data/doc/rdoc/classes/Rev/TimerWatcher.src/M000090.html +27 -0
  143. data/doc/rdoc/classes/Rev/TimerWatcher.src/M000091.html +42 -0
  144. data/doc/rdoc/classes/Rev/TimerWatcher.src/M000092.html +24 -0
  145. data/doc/rdoc/classes/Rev/UNIXListener.html +147 -0
  146. data/doc/rdoc/classes/Rev/UNIXListener.src/M000120.html +18 -0
  147. data/doc/rdoc/classes/Rev/UNIXServer.html +147 -0
  148. data/doc/rdoc/classes/Rev/UNIXServer.src/M000030.html +18 -0
  149. data/doc/rdoc/classes/Rev/UNIXSocket.html +175 -0
  150. data/doc/rdoc/classes/Rev/UNIXSocket.src/M000093.html +18 -0
  151. data/doc/rdoc/classes/Rev/UNIXSocket.src/M000094.html +21 -0
  152. data/doc/rdoc/classes/Rev/Watcher.html +349 -0
  153. data/doc/rdoc/classes/Rev/Watcher.src/M000110.html +20 -0
  154. data/doc/rdoc/classes/Rev/Watcher.src/M000111.html +20 -0
  155. data/doc/rdoc/classes/Rev/Watcher.src/M000112.html +17 -0
  156. data/doc/rdoc/classes/Rev/Watcher.src/M000113.html +48 -0
  157. data/doc/rdoc/classes/Rev/Watcher.src/M000114.html +62 -0
  158. data/doc/rdoc/classes/Rev/Watcher.src/M000115.html +34 -0
  159. data/doc/rdoc/classes/Rev/Watcher.src/M000116.html +34 -0
  160. data/doc/rdoc/classes/Rev/Watcher.src/M000117.html +27 -0
  161. data/doc/rdoc/classes/Rev/Watcher.src/M000118.html +24 -0
  162. data/doc/rdoc/classes/Rev/Watcher.src/M000119.html +27 -0
  163. data/doc/rdoc/created.rid +1 -0
  164. data/doc/rdoc/files/LICENSE.html +165 -0
  165. data/doc/rdoc/files/README.html +297 -0
  166. data/doc/rdoc/files/ext/rev/rev_buffer_c.html +101 -0
  167. data/doc/rdoc/files/ext/rev/rev_ext_c.html +101 -0
  168. data/doc/rdoc/files/ext/rev/rev_io_watcher_c.html +101 -0
  169. data/doc/rdoc/files/ext/rev/rev_loop_c.html +101 -0
  170. data/doc/rdoc/files/ext/rev/rev_timer_watcher_c.html +101 -0
  171. data/doc/rdoc/files/ext/rev/rev_watcher_c.html +101 -0
  172. data/doc/rdoc/files/lib/rev/buffered_io_rb.html +101 -0
  173. data/doc/rdoc/files/lib/rev/dns_resolver_rb.html +101 -0
  174. data/doc/rdoc/files/lib/rev/http_client_rb.html +101 -0
  175. data/doc/rdoc/files/lib/rev/io_watcher_rb.html +101 -0
  176. data/doc/rdoc/files/lib/rev/listener_rb.html +108 -0
  177. data/doc/rdoc/files/lib/rev/loop_rb.html +101 -0
  178. data/doc/rdoc/files/lib/rev/server_rb.html +101 -0
  179. data/doc/rdoc/files/lib/rev/socket_rb.html +109 -0
  180. data/doc/rdoc/files/lib/rev/timer_watcher_rb.html +101 -0
  181. data/doc/rdoc/files/lib/rev/watcher_rb.html +101 -0
  182. data/doc/rdoc/files/lib/rev_rb.html +101 -0
  183. data/doc/rdoc/fr_class_index.html +52 -0
  184. data/doc/rdoc/fr_file_index.html +45 -0
  185. data/doc/rdoc/fr_method_index.html +163 -0
  186. data/doc/rdoc/index.html +24 -0
  187. data/doc/rdoc/rdoc-style.css +208 -0
  188. data/ext/rev/extconf.rb +1 -1
  189. data/ext/rev/rev.h +0 -1
  190. data/ext/rev/rev_buffer.c +606 -0
  191. data/ext/rev/rev_ext.c +1 -0
  192. data/ext/rev/rev_io_watcher.c +53 -19
  193. data/ext/rev/rev_loop.c +12 -35
  194. data/ext/rev/rev_timer_watcher.c +45 -3
  195. data/ext/rev/rev_watcher.c +13 -1
  196. data/lib/http11_client.bundle +0 -0
  197. data/lib/rev.rb +1 -1
  198. data/lib/rev/buffered_io.rb +25 -22
  199. data/lib/rev/dns_resolver.rb +31 -14
  200. data/lib/rev/http_client.rb +88 -91
  201. data/lib/rev/listener.rb +22 -5
  202. data/lib/rev/loop.rb +13 -0
  203. data/lib/rev/server.rb +10 -3
  204. data/lib/rev/socket.rb +30 -9
  205. data/lib/rev/watcher.rb +4 -2
  206. data/lib/rev_ext.bundle +0 -0
  207. metadata +230 -2
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ Rev
9
+
10
+ -->
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
+ <head>
13
+ <title>Rev</title>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
+ </head>
16
+ <frameset rows="20%, 80%">
17
+ <frameset cols="25%,35%,45%">
18
+ <frame src="fr_file_index.html" title="Files" name="Files" />
19
+ <frame src="fr_class_index.html" name="Classes" />
20
+ <frame src="fr_method_index.html" name="Methods" />
21
+ </frameset>
22
+ <frame src="files/README.html" name="docwin" />
23
+ </frameset>
24
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
data/ext/rev/extconf.rb CHANGED
@@ -3,7 +3,7 @@ require 'mkmf'
3
3
  flags = []
4
4
 
5
5
  unless have_func('rb_thread_blocking_region') and have_macro('RB_UBF_DFL', 'ruby.h')
6
- abort "Rev requires (a fairly recent) Ruby 1.9 or greater"
6
+ abort "Rev requires Ruby 1.9.0 or greater"
7
7
  end
8
8
 
9
9
  if have_header('sys/select.h')
data/ext/rev/rev.h CHANGED
@@ -19,7 +19,6 @@ struct Rev_Event
19
19
  struct Rev_Loop
20
20
  {
21
21
  struct ev_loop *ev_loop;
22
- int default_loop;
23
22
 
24
23
  int events_received;
25
24
  int eventbuf_size;
@@ -0,0 +1,606 @@
1
+ /*
2
+ * Copyright (C) 2007 Tony Arcieri
3
+ * You may redistribute this under the terms of the Ruby license.
4
+ * See LICENSE for details
5
+ */
6
+
7
+ #include "ruby.h"
8
+ #include "rubyio.h"
9
+ #include <assert.h>
10
+
11
+ #include <string.h>
12
+ #include <time.h>
13
+ #include <unistd.h>
14
+ #include <errno.h>
15
+
16
+ /* Default number of bytes in each node's buffer */
17
+ #define DEFAULT_NODE_SIZE 65536
18
+
19
+ /* Maximum age of a buffer node in a memory pool, in seconds */
20
+ #define MAX_AGE 900
21
+
22
+ struct buffer {
23
+ unsigned size, node_size;
24
+ struct buffer_node *head, *tail;
25
+ struct buffer_node *pool_head, *pool_tail;
26
+ };
27
+
28
+ struct buffer_node {
29
+ unsigned start, end;
30
+ struct buffer_node *next;
31
+ time_t last_used_at;
32
+ unsigned char data[0];
33
+ };
34
+
35
+ /* Module and object handles */
36
+ static VALUE mRev = Qnil;
37
+ static VALUE cRev_Buffer = Qnil;
38
+
39
+ /* Data allocators and deallocators */
40
+ static VALUE Rev_Buffer_allocate(VALUE klass);
41
+ static void Rev_Buffer_mark(struct buffer *);
42
+ static void Rev_Buffer_free(struct buffer *);
43
+
44
+ /* Method implementations */
45
+ static VALUE Rev_Buffer_initialize(int argc, VALUE *argv, VALUE self);
46
+ static VALUE Rev_Buffer_clear(VALUE self);
47
+ static VALUE Rev_Buffer_size(VALUE self);
48
+ static VALUE Rev_Buffer_empty(VALUE self);
49
+ static VALUE Rev_Buffer_append(VALUE self, VALUE data);
50
+ static VALUE Rev_Buffer_prepend(VALUE self, VALUE data);
51
+ static VALUE Rev_Buffer_read(int argc, VALUE *argv, VALUE self);
52
+ static VALUE Rev_Buffer_to_str(VALUE self);
53
+ static VALUE Rev_Buffer_read_from(VALUE self, VALUE io);
54
+ static VALUE Rev_Buffer_write_to(VALUE self, VALUE io);
55
+
56
+ /* Prototypes for internal functions */
57
+ static struct buffer *buffer_new(void);
58
+ static void buffer_clear(struct buffer *buf);
59
+ static void buffer_free(struct buffer *buf);
60
+ static void buffer_gc(struct buffer *buf);
61
+ static void buffer_prepend(struct buffer *buf, char *str, unsigned len);
62
+ static void buffer_append(struct buffer *buf, char *str, unsigned len);
63
+ static void buffer_read(struct buffer *buf, char *str, unsigned len);
64
+ static void buffer_copy(struct buffer *buf, char *str, unsigned len);
65
+ static int buffer_read_from(struct buffer *buf, int fd);
66
+ static int buffer_write_to(struct buffer *buf, int fd);
67
+
68
+ /*
69
+ * High speed buffering geared towards non-blocking I/O. This was largely
70
+ * written in response to String#slice! being incredibly slow in Ruby 1.9.
71
+ *
72
+ * Data is stored in a byte queue implemented as a linked list of equal size
73
+ * chunks. Since every node in the list is the same size they are easily
74
+ * memory pooled. Routines are provided for high speed non-blocking reads
75
+ * and writes from Ruby IO objects.
76
+ */
77
+ void Init_rev_buffer()
78
+ {
79
+ mRev = rb_define_module("Rev");
80
+ cRev_Buffer = rb_define_class_under(mRev, "Buffer", rb_cObject);
81
+ rb_define_alloc_func(cRev_Buffer, Rev_Buffer_allocate);
82
+
83
+ rb_define_method(cRev_Buffer, "initialize", Rev_Buffer_initialize, -1);
84
+ rb_define_method(cRev_Buffer, "clear", Rev_Buffer_clear, 0);
85
+ rb_define_method(cRev_Buffer, "size", Rev_Buffer_size, 0);
86
+ rb_define_method(cRev_Buffer, "empty?", Rev_Buffer_empty, 0);
87
+ rb_define_method(cRev_Buffer, "<<", Rev_Buffer_append, 1);
88
+ rb_define_method(cRev_Buffer, "append", Rev_Buffer_append, 1);
89
+ rb_define_method(cRev_Buffer, "prepend", Rev_Buffer_prepend, 1);
90
+ rb_define_method(cRev_Buffer, "read", Rev_Buffer_read, -1);
91
+ rb_define_method(cRev_Buffer, "to_str", Rev_Buffer_to_str, 0);
92
+ rb_define_method(cRev_Buffer, "read_from", Rev_Buffer_read_from, 1);
93
+ rb_define_method(cRev_Buffer, "write_to", Rev_Buffer_write_to, 1);
94
+ }
95
+
96
+ static VALUE Rev_Buffer_allocate(VALUE klass)
97
+ {
98
+ return Data_Wrap_Struct(klass, Rev_Buffer_mark, Rev_Buffer_free, buffer_new());
99
+ }
100
+
101
+ static void Rev_Buffer_mark(struct buffer *buf)
102
+ {
103
+ /* Walks the pool of unused chunks and frees any that are beyond a certain age */
104
+ buffer_gc(buf);
105
+ }
106
+
107
+ static void Rev_Buffer_free(struct buffer *buf)
108
+ {
109
+ buffer_free(buf);
110
+ }
111
+
112
+ /**
113
+ * call-seq:
114
+ * Rev::Buffer.new(size = DEFAULT_NODE_SIZE) -> Rev::Buffer
115
+ *
116
+ * Create a new Rev::Buffer with linked segments of the given size
117
+ */
118
+ static VALUE Rev_Buffer_initialize(int argc, VALUE *argv, VALUE self)
119
+ {
120
+ VALUE node_size_obj;
121
+ int node_size;
122
+ struct buffer *buf;
123
+
124
+ if(rb_scan_args(argc, argv, "01", &node_size_obj) == 1) {
125
+ node_size = NUM2INT(node_size_obj);
126
+
127
+ if(node_size < 1) rb_raise(rb_eArgError, "invalid buffer size");
128
+
129
+ Data_Get_Struct(self, struct buffer, buf);
130
+
131
+ /* Make sure we're not changing the buffer size after data has been allocated */
132
+ assert(!buf->head);
133
+ assert(!buf->pool_head);
134
+
135
+ buf->node_size = node_size;
136
+ }
137
+
138
+ return Qnil;
139
+ }
140
+
141
+ /**
142
+ * call-seq:
143
+ * Rev::Buffer#clear -> nil
144
+ *
145
+ * Clear all data from the Rev::Buffer
146
+ */
147
+ static VALUE Rev_Buffer_clear(VALUE self)
148
+ {
149
+ struct buffer *buf;
150
+ Data_Get_Struct(self, struct buffer, buf);
151
+
152
+ buffer_clear(buf);
153
+
154
+ return Qnil;
155
+ }
156
+
157
+ /**
158
+ * call-seq:
159
+ * Rev::Buffer#size -> Integer
160
+ *
161
+ * Return the size of the buffer in bytes
162
+ */
163
+ static VALUE Rev_Buffer_size(VALUE self)
164
+ {
165
+ struct buffer *buf;
166
+ Data_Get_Struct(self, struct buffer, buf);
167
+
168
+ return INT2NUM(buf->size);
169
+ }
170
+
171
+ /**
172
+ * call-seq:
173
+ * Rev::Buffer#empty? -> Boolean
174
+ *
175
+ * Is the buffer empty?
176
+ */
177
+ static VALUE Rev_Buffer_empty(VALUE self)
178
+ {
179
+ struct buffer *buf;
180
+ Data_Get_Struct(self, struct buffer, buf);
181
+
182
+ return buf->size > 0 ? Qfalse : Qtrue;
183
+ }
184
+
185
+ /**
186
+ * call-seq:
187
+ * Rev::Buffer#append(data) -> String
188
+ *
189
+ * Append the given data to the end of the buffer
190
+ */
191
+ static VALUE Rev_Buffer_append(VALUE self, VALUE data)
192
+ {
193
+ struct buffer *buf;
194
+ Data_Get_Struct(self, struct buffer, buf);
195
+
196
+ /* Is this needed? Never seen anyone else do it... */
197
+ data = rb_convert_type(data, T_STRING, "String", "to_str");
198
+ buffer_append(buf, RSTRING_PTR(data), RSTRING_LEN(data));
199
+
200
+ return data;
201
+ }
202
+
203
+ /**
204
+ * call-seq:
205
+ * Rev::Buffer#prepend(data) -> String
206
+ *
207
+ * Prepend the given data to the beginning of the buffer
208
+ */
209
+ static VALUE Rev_Buffer_prepend(VALUE self, VALUE data)
210
+ {
211
+ struct buffer *buf;
212
+ Data_Get_Struct(self, struct buffer, buf);
213
+
214
+ data = rb_convert_type(data, T_STRING, "String", "to_str");
215
+ buffer_prepend(buf, RSTRING_PTR(data), RSTRING_LEN(data));
216
+
217
+ return data;
218
+ }
219
+
220
+ /**
221
+ * call-seq:
222
+ * Rev::Buffer#read(length = nil) -> String
223
+ *
224
+ * Read the specified abount of data from the buffer. If no value
225
+ * is given the entire contents of the buffer are returned. Any data
226
+ * read from the buffer is cleared.
227
+ */
228
+ static VALUE Rev_Buffer_read(int argc, VALUE *argv, VALUE self)
229
+ {
230
+ VALUE length_obj, str;
231
+ int length;
232
+ struct buffer *buf;
233
+
234
+ Data_Get_Struct(self, struct buffer, buf);
235
+
236
+ if(rb_scan_args(argc, argv, "01", &length_obj) == 1) {
237
+ length = NUM2INT(length_obj);
238
+ } else {
239
+ if(buf->size == 0)
240
+ return rb_str_new2("");
241
+
242
+ length = buf->size;
243
+ }
244
+
245
+ if(length > buf->size)
246
+ length = buf->size;
247
+
248
+ if(length < 1)
249
+ rb_raise(rb_eArgError, "length must be greater than zero");
250
+
251
+ str = rb_str_new(0, length);
252
+ buffer_read(buf, RSTRING_PTR(str), length);
253
+
254
+ return str;
255
+ }
256
+
257
+ /**
258
+ * call-seq:
259
+ * Rev::Buffer#to_str -> String
260
+ *
261
+ * Convert the Buffer to a String. The original buffer is unmodified.
262
+ */
263
+ static VALUE Rev_Buffer_to_str(VALUE self) {
264
+ VALUE str;
265
+ struct buffer *buf;
266
+
267
+ Data_Get_Struct(self, struct buffer, buf);
268
+
269
+ str = rb_str_new(0, buf->size);
270
+ buffer_copy(buf, RSTRING_PTR(str), buf->size);
271
+
272
+ return str;
273
+ }
274
+
275
+ /**
276
+ * call-seq:
277
+ * Rev::Buffer#read_from(io) -> Integer
278
+ *
279
+ * Perform a nonblocking read of the the given IO object and fill
280
+ * the buffer with any data received. The call will read as much
281
+ * data as it can until the read would block.
282
+ */
283
+ static VALUE Rev_Buffer_read_from(VALUE self, VALUE io) {
284
+ struct buffer *buf;
285
+ rb_io_t *fptr;
286
+
287
+ Data_Get_Struct(self, struct buffer, buf);
288
+ GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
289
+ rb_io_set_nonblock(fptr);
290
+
291
+ return INT2NUM(buffer_read_from(buf, fptr->fd));
292
+ }
293
+
294
+ /**
295
+ * call-seq:
296
+ * Rev::Buffer#write_to(io) -> Integer
297
+ *
298
+ * Perform a nonblocking write of the buffer to the given IO object.
299
+ * As much data as possible is written until the call would block.
300
+ * Any data which is written is removed from the buffer.
301
+ */
302
+ static VALUE Rev_Buffer_write_to(VALUE self, VALUE io) {
303
+ struct buffer *buf;
304
+ rb_io_t *fptr;
305
+
306
+ Data_Get_Struct(self, struct buffer, buf);
307
+ GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
308
+ rb_io_set_nonblock(fptr);
309
+
310
+ return INT2NUM(buffer_write_to(buf, fptr->fd));
311
+ }
312
+
313
+ /*
314
+ * Ruby bindings end here. Below is the actual implementation of
315
+ * the underlying data structures.
316
+ */
317
+
318
+ /* Create a new buffer */
319
+ static struct buffer *buffer_new(void)
320
+ {
321
+ struct buffer *buf;
322
+ buf = (struct buffer *)xmalloc(sizeof(struct buffer));
323
+ buf->head = buf->tail = buf->pool_head = buf->pool_tail = 0;
324
+ buf->size = 0;
325
+ buf->node_size = DEFAULT_NODE_SIZE;
326
+
327
+ return buf;
328
+ }
329
+
330
+ /* Clear all data from a buffer */
331
+ static void buffer_clear(struct buffer *buf)
332
+ {
333
+ struct buffer_node *tmp;
334
+
335
+ /* Move everything into the buffer pool */
336
+ if(!buf->pool_tail)
337
+ buf->pool_head = buf->pool_tail = buf->head;
338
+ else
339
+ buf->pool_tail->next = buf->head;
340
+
341
+ buf->head = buf->tail = 0;
342
+ buf->size = 0;
343
+ }
344
+
345
+ /* Free a buffer */
346
+ static void buffer_free(struct buffer *buf)
347
+ {
348
+ struct buffer_node *tmp;
349
+
350
+ buffer_clear(buf);
351
+
352
+ while(buf->pool_head) {
353
+ tmp = buf->pool_head;
354
+ buf->pool_head = tmp->next;
355
+ free(tmp);
356
+ }
357
+
358
+ free(buf);
359
+ }
360
+
361
+ /* Run through the pool and find elements that haven't been used for awhile */
362
+ static void buffer_gc(struct buffer *buf)
363
+ {
364
+ struct buffer_node *cur, *tmp;
365
+ time_t now;
366
+ time(&now);
367
+
368
+ while(buf->pool_head && now - buf->pool_head->last_used_at >= MAX_AGE) {
369
+ tmp = buf->pool_head;
370
+ buf->pool_head = buf->pool_head->next;
371
+ free(tmp);
372
+ }
373
+
374
+ if(!buf->pool_head)
375
+ buf->pool_tail = 0;
376
+ }
377
+
378
+ /* Create a new buffer_node (or pull one from the memory pool) */
379
+ static struct buffer_node *buffer_node_new(struct buffer *buf)
380
+ {
381
+ struct buffer_node *node;
382
+
383
+ /* Pull from the memory pool if available */
384
+ if(buf->pool_head) {
385
+ node = buf->pool_head;
386
+ buf->pool_head = node->next;
387
+
388
+ if(node->next)
389
+ node->next = 0;
390
+ else
391
+ buf->pool_tail = 0;
392
+ } else {
393
+ node = (struct buffer_node *)xmalloc(sizeof(struct buffer_node) + buf->node_size);
394
+ node->next = 0;
395
+ }
396
+
397
+ node->start = node->end = 0;
398
+ return node;
399
+ }
400
+
401
+ /* Free a buffer node (i.e. return it to the memory pool) */
402
+ static void buffer_node_free(struct buffer *buf, struct buffer_node *node)
403
+ {
404
+ /* Store when the node was freed */
405
+ time(&node->last_used_at);
406
+
407
+ node->next = buf->pool_head;
408
+ buf->pool_head = node;
409
+
410
+ if(!buf->pool_tail)
411
+ buf->pool_tail = node;
412
+ }
413
+
414
+ /* Prepend data to the front of the buffer */
415
+ static void buffer_prepend(struct buffer *buf, char *str, unsigned len)
416
+ {
417
+ struct buffer_node *node, *tmp;
418
+ buf->size += len;
419
+
420
+ /* If it fits in the beginning of the head */
421
+ if(buf->head && buf->head->start >= len) {
422
+ buf->head->start -= len;
423
+ memcpy(buf->head->data + buf->head->start, str, len);
424
+ } else {
425
+ node = buffer_node_new(buf);
426
+ node->next = buf->head;
427
+ buf->head = node;
428
+ if(!buf->tail) buf->tail = node;
429
+
430
+ while(len > buf->node_size) {
431
+ memcpy(node->data, str, buf->node_size);
432
+ node->end = buf->node_size;
433
+
434
+ tmp = buffer_node_new(buf);
435
+ tmp->next = node->next;
436
+ node->next = tmp;
437
+
438
+ if(buf->tail == node) buf->tail = tmp;
439
+ node = tmp;
440
+
441
+ str += buf->node_size;
442
+ len -= buf->node_size;
443
+ }
444
+
445
+ if(len > 0) {
446
+ memcpy(node->data, str, len);
447
+ node->end = len;
448
+ }
449
+ }
450
+ }
451
+
452
+ /* Append data to the front of the buffer */
453
+ static void buffer_append(struct buffer *buf, char *str, unsigned len)
454
+ {
455
+ unsigned nbytes;
456
+ buf->size += len;
457
+
458
+ /* If it fits in the remaining space in the tail */
459
+ if(buf->tail && len <= buf->node_size - buf->tail->end) {
460
+ memcpy(buf->tail->data + buf->tail->end, str, len);
461
+ buf->tail->end += len;
462
+ return;
463
+ }
464
+
465
+ /* Empty list needs initialized */
466
+ if(!buf->head) {
467
+ buf->head = buffer_node_new(buf);
468
+ buf->tail = buf->head;
469
+ }
470
+
471
+ /* Build links out of the data */
472
+ while(len > 0) {
473
+ nbytes = buf->node_size - buf->tail->end;
474
+ if(len < nbytes) nbytes = len;
475
+
476
+ memcpy(buf->tail->data + buf->tail->end, str, nbytes);
477
+ len -= nbytes;
478
+ buf->tail->end += nbytes;
479
+
480
+ if(len > 0) {
481
+ buf->tail->next = buffer_node_new(buf);
482
+ buf->tail = buf->tail->next;
483
+ }
484
+ }
485
+ }
486
+
487
+ /* Read data from the buffer (and clear what we've read) */
488
+ static void buffer_read(struct buffer *buf, char *str, unsigned len)
489
+ {
490
+ unsigned nbytes;
491
+ struct buffer_node *tmp;
492
+
493
+ while(buf->size > 0 && len > 0) {
494
+ nbytes = buf->head->end - buf->head->start;
495
+ if(len < nbytes) nbytes = len;
496
+
497
+ memcpy(str, buf->head->data + buf->head->start, nbytes);
498
+ str += nbytes;
499
+ len -= nbytes;
500
+
501
+ buf->head->start += nbytes;
502
+ buf->size -= nbytes;
503
+
504
+ if(buf->head->start == buf->head->end) {
505
+ tmp = buf->head;
506
+ buf->head = tmp->next;
507
+ buffer_node_free(buf, tmp);
508
+
509
+ if(!buf->head) buf->tail = 0;
510
+ }
511
+ }
512
+ }
513
+
514
+ /* Copy data from the buffer without clearing it */
515
+ static void buffer_copy(struct buffer *buf, char *str, unsigned len)
516
+ {
517
+ unsigned nbytes;
518
+ struct buffer_node *node;
519
+
520
+ node = buf->head;
521
+ while(node && len > 0) {
522
+ nbytes = node->end - node->start;
523
+ if(len < nbytes) nbytes = len;
524
+
525
+ memcpy(str, node->data + node->start, nbytes);
526
+ str += nbytes;
527
+ len -= nbytes;
528
+
529
+ if(node->start + nbytes == node->end)
530
+ node = node->next;
531
+ }
532
+ }
533
+
534
+ /* Write data from the buffer to a file descriptor */
535
+ static int buffer_write_to(struct buffer *buf, int fd)
536
+ {
537
+ int bytes_written, total_bytes_written = 0;
538
+ struct buffer_node *tmp;
539
+
540
+ while(buf->head) {
541
+ bytes_written = write(fd, buf->head->data + buf->head->start, buf->head->end - buf->head->start);
542
+
543
+ /* If the write failed... */
544
+ if(bytes_written < 1) {
545
+ if(errno == EAGAIN)
546
+ errno = 0;
547
+
548
+ return total_bytes_written;
549
+ }
550
+
551
+ total_bytes_written += bytes_written;
552
+ buf->size -= bytes_written;
553
+
554
+ /* If the write blocked... */
555
+ if(bytes_written < buf->head->end - buf->head->start) {
556
+ buf->head->start += bytes_written;
557
+ return total_bytes_written;
558
+ }
559
+
560
+ /* Otherwise we wrote the whole buffer */
561
+ tmp = buf->head;
562
+ buf->head = tmp->next;
563
+ buffer_node_free(buf, tmp);
564
+
565
+ if(!buf->head) buf->tail = 0;
566
+ }
567
+
568
+ return total_bytes_written;
569
+ }
570
+
571
+ /* Read data from a file descriptor to a buffer */
572
+ /* Append data to the front of the buffer */
573
+ static int buffer_read_from(struct buffer *buf, int fd)
574
+ {
575
+ int bytes_read, total_bytes_read = 0;
576
+ unsigned nbytes;
577
+
578
+ /* Empty list needs initialized */
579
+ if(!buf->head) {
580
+ buf->head = buffer_node_new(buf);
581
+ buf->tail = buf->head;
582
+ }
583
+
584
+ do {
585
+ nbytes = buf->node_size - buf->tail->end;
586
+ bytes_read = read(fd, buf->tail->data + buf->tail->end, nbytes);
587
+
588
+ if(bytes_read < 1) {
589
+ if(errno == EAGAIN)
590
+ errno = 0;
591
+
592
+ return total_bytes_read;
593
+ }
594
+
595
+ total_bytes_read += bytes_read;
596
+ buf->tail->end += nbytes;
597
+ buf->size += nbytes;
598
+
599
+ if(buf->tail->end == buf->node_size) {
600
+ buf->tail->next = buffer_node_new(buf);
601
+ buf->tail = buf->tail->next;
602
+ }
603
+ } while(bytes_read == nbytes);
604
+
605
+ return total_bytes_read;
606
+ }