cool.io 1.8.1 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yaml +1 -0
- data/.gitignore +1 -0
- data/Rakefile +0 -5
- data/cool.io.gemspec +1 -1
- data/ext/{iobuffer/iobuffer.c → cool.io/buffer.c} +104 -93
- data/ext/cool.io/cool.io.h +4 -0
- data/ext/cool.io/cool.io_ext.c +1 -0
- data/ext/cool.io/extconf.rb +6 -1
- data/ext/cool.io/iowatcher.c +1 -1
- data/ext/cool.io/loop.c +28 -14
- data/ext/cool.io/stat_watcher.c +4 -4
- data/ext/cool.io/timer_watcher.c +5 -5
- data/ext/cool.io/watcher.c +30 -17
- data/ext/cool.io/watcher.h +8 -8
- data/{Gemfile → gems.rb} +5 -0
- data/lib/cool.io/dns_resolver.rb +1 -1
- data/lib/cool.io/io.rb +1 -1
- data/lib/cool.io/socket.rb +1 -1
- data/lib/cool.io/version.rb +1 -1
- data/lib/cool.io.rb +0 -1
- data/spec/iobuffer_spec.rb +2 -2
- metadata +5 -11
- data/.travis.yml +0 -16
- data/ext/iobuffer/extconf.rb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d38b3958d9ad5505fb4a53ded526d2ab347d46200a567a9aa0681cc5ca487cc
|
|
4
|
+
data.tar.gz: 42cb1b75db2c409dfc48756b8df29663675e31a104d03c37bbbfce9344592d6d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e3358de317e34735ca0f264c75f93d34d38325482c02eabf4d1289b3c44ef6557918bd59078a34c809322d69d05299ccb58f89db630c4054dc0162de8ab49b6
|
|
7
|
+
data.tar.gz: 775568343fe8788adbc43757a6f06ef5474e1d19477571317f29e21ff3da777d8567a6401377c6eb854e9f0c4060d97da7c84dafa56dc1e772f636417365d338
|
data/.github/workflows/test.yaml
CHANGED
data/.gitignore
CHANGED
data/Rakefile
CHANGED
|
@@ -31,11 +31,6 @@ def configure_cross_compilation(ext)
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
Rake::ExtensionTask.new('iobuffer_ext', spec) do |ext|
|
|
35
|
-
ext.ext_dir = 'ext/iobuffer'
|
|
36
|
-
configure_cross_compilation(ext)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
34
|
Rake::ExtensionTask.new('cool.io_ext', spec) do |ext|
|
|
40
35
|
ext.ext_dir = 'ext/cool.io'
|
|
41
36
|
configure_cross_compilation(ext)
|
data/cool.io.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
|
10
10
|
s.homepage = "https://github.com/socketry/cool.io"
|
|
11
11
|
s.summary = "A cool framework for doing high performance I/O in Ruby"
|
|
12
12
|
s.description = "Cool.io provides a high performance event framework for Ruby which uses the libev C library"
|
|
13
|
-
s.extensions = ["ext/cool.io/extconf.rb"
|
|
13
|
+
s.extensions = ["ext/cool.io/extconf.rb"]
|
|
14
14
|
s.licenses = ["MIT"]
|
|
15
15
|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
|
@@ -43,27 +43,28 @@ struct buffer_node {
|
|
|
43
43
|
unsigned char data[0];
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
static VALUE
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
static
|
|
50
|
-
static void
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
static VALUE
|
|
54
|
-
static VALUE
|
|
55
|
-
static VALUE
|
|
56
|
-
static VALUE
|
|
57
|
-
static VALUE
|
|
58
|
-
static VALUE
|
|
59
|
-
static VALUE
|
|
60
|
-
static VALUE
|
|
61
|
-
static VALUE
|
|
62
|
-
static VALUE
|
|
63
|
-
static VALUE
|
|
64
|
-
static VALUE
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
static VALUE mCoolio = Qnil;
|
|
47
|
+
static VALUE cCoolio_Buffer = Qnil;
|
|
48
|
+
|
|
49
|
+
static VALUE Coolio_Buffer_allocate(VALUE klass);
|
|
50
|
+
static void Coolio_Buffer_mark(void *);
|
|
51
|
+
static void Coolio_Buffer_free(void *);
|
|
52
|
+
|
|
53
|
+
static VALUE Coolio_Buffer_default_node_size(VALUE klass);
|
|
54
|
+
static VALUE Coolio_Buffer_set_default_node_size(VALUE klass, VALUE size);
|
|
55
|
+
static VALUE Coolio_Buffer_initialize(int argc, VALUE * argv, VALUE self);
|
|
56
|
+
static VALUE Coolio_Buffer_clear(VALUE self);
|
|
57
|
+
static VALUE Coolio_Buffer_size(VALUE self);
|
|
58
|
+
static VALUE Coolio_Buffer_empty(VALUE self);
|
|
59
|
+
static VALUE Coolio_Buffer_append(VALUE self, VALUE data);
|
|
60
|
+
static VALUE Coolio_Buffer_prepend(VALUE self, VALUE data);
|
|
61
|
+
static VALUE Coolio_Buffer_read(int argc, VALUE * argv, VALUE self);
|
|
62
|
+
static VALUE Coolio_Buffer_read_frame(VALUE self, VALUE data, VALUE mark);
|
|
63
|
+
static VALUE Coolio_Buffer_to_str(VALUE self);
|
|
64
|
+
static VALUE Coolio_Buffer_read_from(VALUE self, VALUE io);
|
|
65
|
+
static VALUE Coolio_Buffer_write_to(VALUE self, VALUE io);
|
|
66
|
+
|
|
67
|
+
static struct buffer *buffer_init(struct buffer *);
|
|
67
68
|
static void buffer_clear(struct buffer * buf);
|
|
68
69
|
static void buffer_free(struct buffer * buf);
|
|
69
70
|
static void buffer_free_pool(struct buffer * buf);
|
|
@@ -83,60 +84,73 @@ static int buffer_write_to(struct buffer * buf, int fd);
|
|
|
83
84
|
* Ruby IO objects.
|
|
84
85
|
*/
|
|
85
86
|
void
|
|
86
|
-
|
|
87
|
+
Init_coolio_buffer()
|
|
87
88
|
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
rb_define_method(
|
|
98
|
-
rb_define_method(
|
|
99
|
-
rb_define_method(
|
|
100
|
-
rb_define_method(
|
|
101
|
-
rb_define_method(
|
|
102
|
-
rb_define_method(
|
|
103
|
-
rb_define_method(
|
|
104
|
-
rb_define_method(
|
|
105
|
-
rb_define_method(
|
|
106
|
-
rb_define_method(
|
|
107
|
-
rb_define_method(
|
|
108
|
-
rb_define_method(
|
|
109
|
-
|
|
110
|
-
|
|
89
|
+
mCoolio = rb_define_module("Coolio");
|
|
90
|
+
cCoolio_Buffer = rb_define_class_under(mCoolio, "Buffer", rb_cObject);
|
|
91
|
+
rb_define_alloc_func(cCoolio_Buffer, Coolio_Buffer_allocate);
|
|
92
|
+
|
|
93
|
+
rb_define_singleton_method(cCoolio_Buffer, "default_node_size",
|
|
94
|
+
Coolio_Buffer_default_node_size, 0);
|
|
95
|
+
rb_define_singleton_method(cCoolio_Buffer, "default_node_size=",
|
|
96
|
+
Coolio_Buffer_set_default_node_size, 1);
|
|
97
|
+
|
|
98
|
+
rb_define_method(cCoolio_Buffer, "initialize", Coolio_Buffer_initialize, -1);
|
|
99
|
+
rb_define_method(cCoolio_Buffer, "clear", Coolio_Buffer_clear, 0);
|
|
100
|
+
rb_define_method(cCoolio_Buffer, "size", Coolio_Buffer_size, 0);
|
|
101
|
+
rb_define_method(cCoolio_Buffer, "empty?", Coolio_Buffer_empty, 0);
|
|
102
|
+
rb_define_method(cCoolio_Buffer, "<<", Coolio_Buffer_append, 1);
|
|
103
|
+
rb_define_method(cCoolio_Buffer, "append", Coolio_Buffer_append, 1);
|
|
104
|
+
rb_define_method(cCoolio_Buffer, "write", Coolio_Buffer_append, 1);
|
|
105
|
+
rb_define_method(cCoolio_Buffer, "prepend", Coolio_Buffer_prepend, 1);
|
|
106
|
+
rb_define_method(cCoolio_Buffer, "read", Coolio_Buffer_read, -1);
|
|
107
|
+
rb_define_method(cCoolio_Buffer, "read_frame", Coolio_Buffer_read_frame, 2);
|
|
108
|
+
rb_define_method(cCoolio_Buffer, "to_str", Coolio_Buffer_to_str, 0);
|
|
109
|
+
rb_define_method(cCoolio_Buffer, "read_from", Coolio_Buffer_read_from, 1);
|
|
110
|
+
rb_define_method(cCoolio_Buffer, "write_to", Coolio_Buffer_write_to, 1);
|
|
111
|
+
|
|
112
|
+
rb_define_const(cCoolio_Buffer, "MAX_SIZE", INT2NUM(MAX_BUFFER_SIZE));
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
static const rb_data_type_t Coolio_Buffer_type = {
|
|
116
|
+
"Coolio::Buffer",
|
|
117
|
+
{
|
|
118
|
+
Coolio_Buffer_mark,
|
|
119
|
+
Coolio_Buffer_free,
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
113
123
|
static VALUE
|
|
114
|
-
|
|
124
|
+
Coolio_Buffer_allocate(VALUE klass)
|
|
115
125
|
{
|
|
116
|
-
|
|
126
|
+
struct buffer *buf;
|
|
127
|
+
VALUE buffer = TypedData_Make_Struct(klass, struct buffer, &Coolio_Buffer_type, buf);
|
|
128
|
+
|
|
129
|
+
buffer_init(buf);
|
|
130
|
+
return buffer;
|
|
117
131
|
}
|
|
118
132
|
|
|
119
133
|
static void
|
|
120
|
-
|
|
134
|
+
Coolio_Buffer_mark(void *buf)
|
|
121
135
|
{
|
|
122
136
|
/* Naively discard the memory pool whenever Ruby garbage collects */
|
|
123
137
|
buffer_free_pool(buf);
|
|
124
138
|
}
|
|
125
139
|
|
|
126
140
|
static void
|
|
127
|
-
|
|
141
|
+
Coolio_Buffer_free(void * buf)
|
|
128
142
|
{
|
|
129
143
|
buffer_free(buf);
|
|
130
144
|
}
|
|
131
145
|
|
|
132
146
|
/**
|
|
133
147
|
* call-seq:
|
|
134
|
-
*
|
|
148
|
+
* Coolio::Buffer.default_node_size -> 4096
|
|
135
149
|
*
|
|
136
150
|
* Retrieves the current value of the default node size.
|
|
137
151
|
*/
|
|
138
152
|
static VALUE
|
|
139
|
-
|
|
153
|
+
Coolio_Buffer_default_node_size(VALUE klass)
|
|
140
154
|
{
|
|
141
155
|
return UINT2NUM(default_node_size);
|
|
142
156
|
}
|
|
@@ -159,12 +173,12 @@ convert_node_size(VALUE size)
|
|
|
159
173
|
|
|
160
174
|
/**
|
|
161
175
|
* call-seq:
|
|
162
|
-
*
|
|
176
|
+
* Coolio::Buffer.default_node_size = 16384
|
|
163
177
|
*
|
|
164
|
-
* Sets the default node size for calling
|
|
178
|
+
* Sets the default node size for calling Coolio::Buffer.new with no arguments.
|
|
165
179
|
*/
|
|
166
180
|
static VALUE
|
|
167
|
-
|
|
181
|
+
Coolio_Buffer_set_default_node_size(VALUE klass, VALUE size)
|
|
168
182
|
{
|
|
169
183
|
default_node_size = convert_node_size(size);
|
|
170
184
|
|
|
@@ -173,18 +187,18 @@ IO_Buffer_set_default_node_size(VALUE klass, VALUE size)
|
|
|
173
187
|
|
|
174
188
|
/**
|
|
175
189
|
* call-seq:
|
|
176
|
-
*
|
|
190
|
+
* Coolio::Buffer.new(size = Coolio::Buffer.default_node_size) -> Coolio::Buffer
|
|
177
191
|
*
|
|
178
|
-
* Create a new
|
|
192
|
+
* Create a new Coolio::Buffer with linked segments of the given size
|
|
179
193
|
*/
|
|
180
194
|
static VALUE
|
|
181
|
-
|
|
195
|
+
Coolio_Buffer_initialize(int argc, VALUE * argv, VALUE self)
|
|
182
196
|
{
|
|
183
197
|
VALUE node_size_obj;
|
|
184
198
|
struct buffer *buf;
|
|
185
199
|
|
|
186
200
|
if (rb_scan_args(argc, argv, "01", &node_size_obj) == 1) {
|
|
187
|
-
|
|
201
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
188
202
|
|
|
189
203
|
/*
|
|
190
204
|
* Make sure we're not changing the buffer size after data
|
|
@@ -200,15 +214,15 @@ IO_Buffer_initialize(int argc, VALUE * argv, VALUE self)
|
|
|
200
214
|
|
|
201
215
|
/**
|
|
202
216
|
* call-seq:
|
|
203
|
-
*
|
|
217
|
+
* Coolio::Buffer#clear -> nil
|
|
204
218
|
*
|
|
205
|
-
* Clear all data from the
|
|
219
|
+
* Clear all data from the Coolio::Buffer
|
|
206
220
|
*/
|
|
207
221
|
static VALUE
|
|
208
|
-
|
|
222
|
+
Coolio_Buffer_clear(VALUE self)
|
|
209
223
|
{
|
|
210
224
|
struct buffer *buf;
|
|
211
|
-
|
|
225
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
212
226
|
|
|
213
227
|
buffer_clear(buf);
|
|
214
228
|
|
|
@@ -217,45 +231,45 @@ IO_Buffer_clear(VALUE self)
|
|
|
217
231
|
|
|
218
232
|
/**
|
|
219
233
|
* call-seq:
|
|
220
|
-
*
|
|
234
|
+
* Coolio::Buffer#size -> Integer
|
|
221
235
|
*
|
|
222
236
|
* Return the size of the buffer in bytes
|
|
223
237
|
*/
|
|
224
238
|
static VALUE
|
|
225
|
-
|
|
239
|
+
Coolio_Buffer_size(VALUE self)
|
|
226
240
|
{
|
|
227
241
|
struct buffer *buf;
|
|
228
|
-
|
|
242
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
229
243
|
|
|
230
244
|
return INT2NUM(buf->size);
|
|
231
245
|
}
|
|
232
246
|
|
|
233
247
|
/**
|
|
234
248
|
* call-seq:
|
|
235
|
-
*
|
|
249
|
+
* Coolio::Buffer#empty? -> Boolean
|
|
236
250
|
*
|
|
237
251
|
* Is the buffer empty?
|
|
238
252
|
*/
|
|
239
253
|
static VALUE
|
|
240
|
-
|
|
254
|
+
Coolio_Buffer_empty(VALUE self)
|
|
241
255
|
{
|
|
242
256
|
struct buffer *buf;
|
|
243
|
-
|
|
257
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
244
258
|
|
|
245
259
|
return buf->size > 0 ? Qfalse : Qtrue;
|
|
246
260
|
}
|
|
247
261
|
|
|
248
262
|
/**
|
|
249
263
|
* call-seq:
|
|
250
|
-
*
|
|
264
|
+
* Coolio::Buffer#append(data) -> String
|
|
251
265
|
*
|
|
252
266
|
* Append the given data to the end of the buffer
|
|
253
267
|
*/
|
|
254
268
|
static VALUE
|
|
255
|
-
|
|
269
|
+
Coolio_Buffer_append(VALUE self, VALUE data)
|
|
256
270
|
{
|
|
257
271
|
struct buffer *buf;
|
|
258
|
-
|
|
272
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
259
273
|
|
|
260
274
|
/* Is this needed? Never seen anyone else do it... */
|
|
261
275
|
data = rb_convert_type(data, T_STRING, "String", "to_str");
|
|
@@ -266,15 +280,15 @@ IO_Buffer_append(VALUE self, VALUE data)
|
|
|
266
280
|
|
|
267
281
|
/**
|
|
268
282
|
* call-seq:
|
|
269
|
-
*
|
|
283
|
+
* Coolio::Buffer#prepend(data) -> String
|
|
270
284
|
*
|
|
271
285
|
* Prepend the given data to the beginning of the buffer
|
|
272
286
|
*/
|
|
273
287
|
static VALUE
|
|
274
|
-
|
|
288
|
+
Coolio_Buffer_prepend(VALUE self, VALUE data)
|
|
275
289
|
{
|
|
276
290
|
struct buffer *buf;
|
|
277
|
-
|
|
291
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
278
292
|
|
|
279
293
|
data = rb_convert_type(data, T_STRING, "String", "to_str");
|
|
280
294
|
buffer_prepend(buf, RSTRING_PTR(data), RSTRING_LEN(data));
|
|
@@ -284,7 +298,7 @@ IO_Buffer_prepend(VALUE self, VALUE data)
|
|
|
284
298
|
|
|
285
299
|
/**
|
|
286
300
|
* call-seq:
|
|
287
|
-
*
|
|
301
|
+
* Coolio::Buffer#read(length = nil) -> String
|
|
288
302
|
*
|
|
289
303
|
* Read the specified abount of data from the buffer. If no value
|
|
290
304
|
* is given the entire contents of the buffer are returned. Any data
|
|
@@ -294,13 +308,13 @@ IO_Buffer_prepend(VALUE self, VALUE data)
|
|
|
294
308
|
* the given length).
|
|
295
309
|
*/
|
|
296
310
|
static VALUE
|
|
297
|
-
|
|
311
|
+
Coolio_Buffer_read(int argc, VALUE * argv, VALUE self)
|
|
298
312
|
{
|
|
299
313
|
VALUE length_obj, str;
|
|
300
314
|
int length;
|
|
301
315
|
struct buffer *buf;
|
|
302
316
|
|
|
303
|
-
|
|
317
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
304
318
|
|
|
305
319
|
if (rb_scan_args(argc, argv, "01", &length_obj) == 1) {
|
|
306
320
|
length = NUM2INT(length_obj);
|
|
@@ -322,7 +336,7 @@ IO_Buffer_read(int argc, VALUE * argv, VALUE self)
|
|
|
322
336
|
|
|
323
337
|
/**
|
|
324
338
|
* call-seq:
|
|
325
|
-
*
|
|
339
|
+
* Coolio::Buffer#read_frame(str, mark) -> boolean
|
|
326
340
|
*
|
|
327
341
|
* Read up to and including the given frame marker (expressed a a
|
|
328
342
|
* Fixnum 0-255) byte, copying into the supplied string object. If the mark is
|
|
@@ -331,12 +345,12 @@ IO_Buffer_read(int argc, VALUE * argv, VALUE self)
|
|
|
331
345
|
*
|
|
332
346
|
*/
|
|
333
347
|
static VALUE
|
|
334
|
-
|
|
348
|
+
Coolio_Buffer_read_frame(VALUE self, VALUE data, VALUE mark)
|
|
335
349
|
{
|
|
336
350
|
char mark_c = (char) NUM2INT(mark);
|
|
337
351
|
struct buffer *buf;
|
|
338
352
|
|
|
339
|
-
|
|
353
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
340
354
|
|
|
341
355
|
if (buffer_read_frame(buf, data, mark_c)) {
|
|
342
356
|
return Qtrue;
|
|
@@ -347,17 +361,17 @@ IO_Buffer_read_frame(VALUE self, VALUE data, VALUE mark)
|
|
|
347
361
|
|
|
348
362
|
/**
|
|
349
363
|
* call-seq:
|
|
350
|
-
*
|
|
364
|
+
* Coolio::Buffer#to_str -> String
|
|
351
365
|
*
|
|
352
366
|
* Convert the Buffer to a String. The original buffer is unmodified.
|
|
353
367
|
*/
|
|
354
368
|
static VALUE
|
|
355
|
-
|
|
369
|
+
Coolio_Buffer_to_str(VALUE self)
|
|
356
370
|
{
|
|
357
371
|
VALUE str;
|
|
358
372
|
struct buffer *buf;
|
|
359
373
|
|
|
360
|
-
|
|
374
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
361
375
|
|
|
362
376
|
str = rb_str_new(0, buf->size);
|
|
363
377
|
buffer_copy(buf, RSTRING_PTR(str), buf->size);
|
|
@@ -367,14 +381,14 @@ IO_Buffer_to_str(VALUE self)
|
|
|
367
381
|
|
|
368
382
|
/**
|
|
369
383
|
* call-seq:
|
|
370
|
-
*
|
|
384
|
+
* Coolio::Buffer#read_from(io) -> Integer
|
|
371
385
|
*
|
|
372
386
|
* Perform a nonblocking read of the the given IO object and fill
|
|
373
387
|
* the buffer with any data received. The call will read as much
|
|
374
388
|
* data as it can until the read would block.
|
|
375
389
|
*/
|
|
376
390
|
static VALUE
|
|
377
|
-
|
|
391
|
+
Coolio_Buffer_read_from(VALUE self, VALUE io)
|
|
378
392
|
{
|
|
379
393
|
struct buffer *buf;
|
|
380
394
|
int ret;
|
|
@@ -384,7 +398,7 @@ IO_Buffer_read_from(VALUE self, VALUE io)
|
|
|
384
398
|
OpenFile *fptr;
|
|
385
399
|
#endif
|
|
386
400
|
|
|
387
|
-
|
|
401
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
388
402
|
io = rb_convert_type(io, T_FILE, "IO", "to_io");
|
|
389
403
|
GetOpenFile(io, fptr);
|
|
390
404
|
rb_io_set_nonblock(fptr);
|
|
@@ -399,14 +413,14 @@ IO_Buffer_read_from(VALUE self, VALUE io)
|
|
|
399
413
|
|
|
400
414
|
/**
|
|
401
415
|
* call-seq:
|
|
402
|
-
*
|
|
416
|
+
* Coolio::Buffer#write_to(io) -> Integer
|
|
403
417
|
*
|
|
404
418
|
* Perform a nonblocking write of the buffer to the given IO object.
|
|
405
419
|
* As much data as possible is written until the call would block.
|
|
406
420
|
* Any data which is written is removed from the buffer.
|
|
407
421
|
*/
|
|
408
422
|
static VALUE
|
|
409
|
-
|
|
423
|
+
Coolio_Buffer_write_to(VALUE self, VALUE io)
|
|
410
424
|
{
|
|
411
425
|
struct buffer *buf;
|
|
412
426
|
#if defined(HAVE_RB_IO_T) || defined(HAVE_RB_IO_DESCRIPTOR)
|
|
@@ -415,7 +429,7 @@ IO_Buffer_write_to(VALUE self, VALUE io)
|
|
|
415
429
|
OpenFile *fptr;
|
|
416
430
|
#endif
|
|
417
431
|
|
|
418
|
-
|
|
432
|
+
TypedData_Get_Struct(self, struct buffer, &Coolio_Buffer_type, buf);
|
|
419
433
|
io = rb_convert_type(io, T_FILE, "IO", "to_io");
|
|
420
434
|
GetOpenFile(io, fptr);
|
|
421
435
|
rb_io_set_nonblock(fptr);
|
|
@@ -434,11 +448,8 @@ IO_Buffer_write_to(VALUE self, VALUE io)
|
|
|
434
448
|
|
|
435
449
|
/* Create a new buffer */
|
|
436
450
|
static struct buffer *
|
|
437
|
-
|
|
451
|
+
buffer_init(struct buffer *buf)
|
|
438
452
|
{
|
|
439
|
-
struct buffer *buf;
|
|
440
|
-
|
|
441
|
-
buf = (struct buffer *) xmalloc(sizeof(struct buffer));
|
|
442
453
|
buf->head = buf->tail = buf->pool_head = buf->pool_tail = 0;
|
|
443
454
|
buf->size = 0;
|
|
444
455
|
buf->node_size = default_node_size;
|
data/ext/cool.io/cool.io.h
CHANGED
|
@@ -60,6 +60,7 @@ struct Coolio_Watcher
|
|
|
60
60
|
|
|
61
61
|
void Coolio_Loop_process_event(VALUE watcher, int revents);
|
|
62
62
|
|
|
63
|
+
void Init_coolio_buffer();
|
|
63
64
|
void Init_coolio_loop();
|
|
64
65
|
void Init_coolio_watcher();
|
|
65
66
|
void Init_coolio_iowatcher();
|
|
@@ -67,4 +68,7 @@ void Init_coolio_timer_watcher();
|
|
|
67
68
|
void Init_coolio_stat_watcher();
|
|
68
69
|
void Init_coolio_utils();
|
|
69
70
|
|
|
71
|
+
struct Coolio_Loop *Coolio_Loop_ptr(VALUE loop);
|
|
72
|
+
struct Coolio_Watcher *Coolio_Watcher_ptr(VALUE watcher);
|
|
73
|
+
|
|
70
74
|
#endif
|
data/ext/cool.io/cool.io_ext.c
CHANGED
data/ext/cool.io/extconf.rb
CHANGED
|
@@ -11,6 +11,12 @@ have_func('rb_thread_alone')
|
|
|
11
11
|
have_func('rb_str_set_len')
|
|
12
12
|
have_library('rt', 'clock_gettime')
|
|
13
13
|
|
|
14
|
+
have_func("rb_io_descriptor")
|
|
15
|
+
have_library("c", "main")
|
|
16
|
+
if have_macro("HAVE_RB_IO_T", "ruby/io.h")
|
|
17
|
+
have_struct_member("rb_io_t", "fd", "ruby/io.h")
|
|
18
|
+
end
|
|
19
|
+
|
|
14
20
|
if have_header('ruby/io.h')
|
|
15
21
|
$defs << '-DHAVE_RUBY_IO_H'
|
|
16
22
|
end
|
|
@@ -72,4 +78,3 @@ if RUBY_PLATFORM =~ /mingw|mswin/
|
|
|
72
78
|
makefile_contents.gsub! /LIBS = (.*) (\S*ws2_32\S*)/i, 'LIBS = \\2 \\1'
|
|
73
79
|
File.open('Makefile', 'w') { |f| f.write makefile_contents }
|
|
74
80
|
end
|
|
75
|
-
|
data/ext/cool.io/iowatcher.c
CHANGED
|
@@ -82,7 +82,7 @@ static VALUE Coolio_IOWatcher_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
82
82
|
else
|
|
83
83
|
rb_raise(rb_eArgError, "invalid event type: '%s' (must be 'r', 'w', or 'rw')", flags_str);
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
86
86
|
io = rb_convert_type(io, T_FILE, "IO", "to_io");
|
|
87
87
|
|
|
88
88
|
watcher_data->dispatch_callback = Coolio_IOWatcher_dispatch_callback;
|
data/ext/cool.io/loop.c
CHANGED
|
@@ -14,8 +14,7 @@ static VALUE mCoolio = Qnil;
|
|
|
14
14
|
static VALUE cCoolio_Loop = Qnil;
|
|
15
15
|
|
|
16
16
|
static VALUE Coolio_Loop_allocate(VALUE klass);
|
|
17
|
-
static void
|
|
18
|
-
static void Coolio_Loop_free(struct Coolio_Loop *loop);
|
|
17
|
+
static void Coolio_Loop_free(void *data);
|
|
19
18
|
|
|
20
19
|
static VALUE Coolio_Loop_ev_loop_new(VALUE self, VALUE flags);
|
|
21
20
|
static VALUE Coolio_Loop_run_once(int argc, VALUE *argv, VALUE self);
|
|
@@ -47,9 +46,26 @@ void Init_coolio_loop()
|
|
|
47
46
|
rb_define_method(cCoolio_Loop, "run_nonblock", Coolio_Loop_run_nonblock, 0);
|
|
48
47
|
}
|
|
49
48
|
|
|
49
|
+
static const rb_data_type_t Coolio_Loop_type = {
|
|
50
|
+
"Coolio::Loop",
|
|
51
|
+
{
|
|
52
|
+
NULL,
|
|
53
|
+
Coolio_Loop_free,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
struct Coolio_Loop *Coolio_Loop_ptr(VALUE self)
|
|
58
|
+
{
|
|
59
|
+
struct Coolio_Loop *loop;
|
|
60
|
+
|
|
61
|
+
TypedData_Get_Struct(self, struct Coolio_Loop, &Coolio_Loop_type, loop);
|
|
62
|
+
return loop;
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
static VALUE Coolio_Loop_allocate(VALUE klass)
|
|
51
66
|
{
|
|
52
|
-
struct Coolio_Loop *loop
|
|
67
|
+
struct Coolio_Loop *loop;
|
|
68
|
+
VALUE obj = TypedData_Make_Struct(klass, struct Coolio_Loop, &Coolio_Loop_type, loop);
|
|
53
69
|
|
|
54
70
|
loop->ev_loop = 0;
|
|
55
71
|
ev_init(&loop->timer, Coolio_Loop_timeout_callback);
|
|
@@ -58,15 +74,13 @@ static VALUE Coolio_Loop_allocate(VALUE klass)
|
|
|
58
74
|
loop->eventbuf_size = DEFAULT_EVENTBUF_SIZE;
|
|
59
75
|
loop->eventbuf = (struct Coolio_Event *)xmalloc(sizeof(struct Coolio_Event) * DEFAULT_EVENTBUF_SIZE);
|
|
60
76
|
|
|
61
|
-
return
|
|
77
|
+
return obj;
|
|
62
78
|
}
|
|
63
79
|
|
|
64
|
-
static void
|
|
80
|
+
static void Coolio_Loop_free(void *data)
|
|
65
81
|
{
|
|
66
|
-
|
|
82
|
+
struct Coolio_Loop *loop = data;
|
|
67
83
|
|
|
68
|
-
static void Coolio_Loop_free(struct Coolio_Loop *loop)
|
|
69
|
-
{
|
|
70
84
|
if(!loop->ev_loop)
|
|
71
85
|
return;
|
|
72
86
|
|
|
@@ -80,7 +94,7 @@ static void Coolio_Loop_free(struct Coolio_Loop *loop)
|
|
|
80
94
|
static VALUE Coolio_Loop_ev_loop_new(VALUE self, VALUE flags)
|
|
81
95
|
{
|
|
82
96
|
struct Coolio_Loop *loop_data;
|
|
83
|
-
|
|
97
|
+
loop_data = Coolio_Loop_ptr(self);
|
|
84
98
|
|
|
85
99
|
if(loop_data->ev_loop)
|
|
86
100
|
rb_raise(rb_eRuntimeError, "loop already initialized");
|
|
@@ -98,8 +112,8 @@ void Coolio_Loop_process_event(VALUE watcher, int revents)
|
|
|
98
112
|
|
|
99
113
|
/* The Global VM lock isn't held right now, but hopefully
|
|
100
114
|
* we can still do this safely */
|
|
101
|
-
|
|
102
|
-
|
|
115
|
+
watcher_data = Coolio_Watcher_ptr(watcher);
|
|
116
|
+
loop_data = Coolio_Loop_ptr(watcher_data->loop);
|
|
103
117
|
|
|
104
118
|
/* Well, what better place to explain how this all works than
|
|
105
119
|
* where the most wonky and convoluted stuff is going on!
|
|
@@ -184,7 +198,7 @@ static VALUE Coolio_Loop_run_once(int argc, VALUE *argv, VALUE self)
|
|
|
184
198
|
rb_raise(rb_eArgError, "time interval must be positive");
|
|
185
199
|
}
|
|
186
200
|
|
|
187
|
-
|
|
201
|
+
loop_data = Coolio_Loop_ptr(self);
|
|
188
202
|
|
|
189
203
|
assert(loop_data->ev_loop && !loop_data->events_received);
|
|
190
204
|
|
|
@@ -222,7 +236,7 @@ static VALUE Coolio_Loop_run_nonblock(VALUE self)
|
|
|
222
236
|
struct Coolio_Loop *loop_data;
|
|
223
237
|
VALUE nevents;
|
|
224
238
|
|
|
225
|
-
|
|
239
|
+
loop_data = Coolio_Loop_ptr(self);
|
|
226
240
|
|
|
227
241
|
assert(loop_data->ev_loop && !loop_data->events_received);
|
|
228
242
|
|
|
@@ -247,7 +261,7 @@ static void Coolio_Loop_dispatch_events(struct Coolio_Loop *loop_data)
|
|
|
247
261
|
if(loop_data->eventbuf[i].watcher == Qnil)
|
|
248
262
|
continue;
|
|
249
263
|
|
|
250
|
-
|
|
264
|
+
watcher_data = Coolio_Watcher_ptr(loop_data->eventbuf[i].watcher);
|
|
251
265
|
watcher_data->dispatch_callback(loop_data->eventbuf[i].watcher, loop_data->eventbuf[i].revents);
|
|
252
266
|
}
|
|
253
267
|
}
|
data/ext/cool.io/stat_watcher.c
CHANGED
|
@@ -89,7 +89,7 @@ static VALUE Coolio_StatWatcher_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
89
89
|
path = rb_String(path);
|
|
90
90
|
rb_iv_set(self, "@path", path);
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
93
93
|
|
|
94
94
|
watcher_data->dispatch_callback = Coolio_StatWatcher_dispatch_callback;
|
|
95
95
|
ev_stat_init(
|
|
@@ -119,8 +119,8 @@ static VALUE Coolio_StatWatcher_attach(VALUE self, VALUE loop)
|
|
|
119
119
|
if(!rb_obj_is_kind_of(loop, cCoolio_Loop))
|
|
120
120
|
rb_raise(rb_eArgError, "expected loop to be an instance of Coolio::Loop, not %s", RSTRING_PTR(rb_inspect(loop)));
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
loop_data = Coolio_Loop_ptr(loop);
|
|
123
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
124
124
|
|
|
125
125
|
if(watcher_data->loop != Qnil)
|
|
126
126
|
Coolio_StatWatcher_detach(self);
|
|
@@ -206,7 +206,7 @@ static void Coolio_StatWatcher_libev_callback(struct ev_loop *ev_loop, struct ev
|
|
|
206
206
|
static void Coolio_StatWatcher_dispatch_callback(VALUE self, int revents)
|
|
207
207
|
{
|
|
208
208
|
struct Coolio_Watcher *watcher_data;
|
|
209
|
-
|
|
209
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
210
210
|
|
|
211
211
|
VALUE previous_statdata = Coolio_StatInfo_build(&watcher_data->event_types.ev_stat.prev);
|
|
212
212
|
VALUE current_statdata = Coolio_StatInfo_build(&watcher_data->event_types.ev_stat.attr);
|
data/ext/cool.io/timer_watcher.c
CHANGED
|
@@ -68,7 +68,7 @@ static VALUE Coolio_TimerWatcher_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
68
68
|
rb_iv_set(self, "@interval", interval);
|
|
69
69
|
rb_iv_set(self, "@repeating", repeating);
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
72
72
|
|
|
73
73
|
watcher_data->dispatch_callback = Coolio_TimerWatcher_dispatch_callback;
|
|
74
74
|
ev_timer_init(
|
|
@@ -98,8 +98,8 @@ static VALUE Coolio_TimerWatcher_attach(VALUE self, VALUE loop)
|
|
|
98
98
|
if(!rb_obj_is_kind_of(loop, cCoolio_Loop))
|
|
99
99
|
rb_raise(rb_eArgError, "expected loop to be an instance of Coolio::Loop, not %s", RSTRING_PTR(rb_inspect(loop)));
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
loop_data = Coolio_Loop_ptr(loop);
|
|
102
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
103
103
|
|
|
104
104
|
if(watcher_data->loop != Qnil)
|
|
105
105
|
Coolio_TimerWatcher_detach(self);
|
|
@@ -180,12 +180,12 @@ static VALUE Coolio_TimerWatcher_reset(VALUE self)
|
|
|
180
180
|
struct Coolio_Watcher *watcher_data;
|
|
181
181
|
struct Coolio_Loop *loop_data;
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
184
184
|
|
|
185
185
|
if(watcher_data->loop == Qnil)
|
|
186
186
|
rb_raise(rb_eRuntimeError, "not attached to a loop");
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
loop_data = Coolio_Loop_ptr(watcher_data->loop);
|
|
189
189
|
|
|
190
190
|
ev_timer_again(loop_data->ev_loop, &watcher_data->event_types.ev_timer);
|
|
191
191
|
|
data/ext/cool.io/watcher.c
CHANGED
|
@@ -13,8 +13,7 @@ static VALUE mCoolio = Qnil;
|
|
|
13
13
|
static VALUE cCoolio_Watcher = Qnil;
|
|
14
14
|
|
|
15
15
|
static VALUE Coolio_Watcher_allocate(VALUE klass);
|
|
16
|
-
static void Coolio_Watcher_mark(
|
|
17
|
-
static void Coolio_Watcher_free(struct Coolio_Watcher *watcher);
|
|
16
|
+
static void Coolio_Watcher_mark(void *data);
|
|
18
17
|
|
|
19
18
|
static VALUE Coolio_Watcher_initialize(VALUE self);
|
|
20
19
|
static VALUE Coolio_Watcher_attach(VALUE self, VALUE loop);
|
|
@@ -53,27 +52,41 @@ void Init_coolio_watcher()
|
|
|
53
52
|
rb_define_method(cCoolio_Watcher, "enabled?", Coolio_Watcher_enabled, 0);
|
|
54
53
|
}
|
|
55
54
|
|
|
55
|
+
static const rb_data_type_t Coolio_Watcher_type = {
|
|
56
|
+
"Coolio::Watcher",
|
|
57
|
+
{
|
|
58
|
+
Coolio_Watcher_mark,
|
|
59
|
+
RUBY_DEFAULT_FREE,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
struct Coolio_Watcher *Coolio_Watcher_ptr(VALUE watcher)
|
|
64
|
+
{
|
|
65
|
+
struct Coolio_Watcher *watcher_data;
|
|
66
|
+
|
|
67
|
+
TypedData_Get_Struct(watcher, struct Coolio_Watcher, &Coolio_Watcher_type, watcher_data);
|
|
68
|
+
return watcher_data;
|
|
69
|
+
}
|
|
70
|
+
|
|
56
71
|
static VALUE Coolio_Watcher_allocate(VALUE klass)
|
|
57
72
|
{
|
|
58
|
-
struct Coolio_Watcher *watcher_data
|
|
73
|
+
struct Coolio_Watcher *watcher_data;
|
|
74
|
+
VALUE watcher = TypedData_Make_Struct(klass, struct Coolio_Watcher, &Coolio_Watcher_type, watcher_data);
|
|
59
75
|
|
|
60
76
|
watcher_data->loop = Qnil;
|
|
61
77
|
watcher_data->enabled = 0;
|
|
62
78
|
|
|
63
|
-
return
|
|
79
|
+
return watcher;
|
|
64
80
|
}
|
|
65
81
|
|
|
66
|
-
static void Coolio_Watcher_mark(
|
|
82
|
+
static void Coolio_Watcher_mark(void *data)
|
|
67
83
|
{
|
|
84
|
+
struct Coolio_Watcher *watcher_data = data;
|
|
85
|
+
|
|
68
86
|
if(watcher_data->loop != Qnil)
|
|
69
87
|
rb_gc_mark(watcher_data->loop);
|
|
70
88
|
}
|
|
71
89
|
|
|
72
|
-
static void Coolio_Watcher_free(struct Coolio_Watcher *watcher_data)
|
|
73
|
-
{
|
|
74
|
-
xfree(watcher_data);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
90
|
static VALUE Coolio_Watcher_initialize(VALUE self)
|
|
78
91
|
{
|
|
79
92
|
rb_raise(rb_eRuntimeError, "watcher base class should not be initialized directly");
|
|
@@ -91,7 +104,7 @@ static VALUE Coolio_Watcher_attach(VALUE self, VALUE loop)
|
|
|
91
104
|
VALUE loop_watchers, active_watchers;
|
|
92
105
|
struct Coolio_Watcher *watcher_data;
|
|
93
106
|
|
|
94
|
-
|
|
107
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
95
108
|
watcher_data->enabled = 1;
|
|
96
109
|
|
|
97
110
|
loop_watchers = rb_iv_get(loop, "@watchers");
|
|
@@ -132,7 +145,7 @@ static VALUE Coolio_Watcher_detach(VALUE self)
|
|
|
132
145
|
VALUE loop_watchers;
|
|
133
146
|
int i;
|
|
134
147
|
|
|
135
|
-
|
|
148
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
136
149
|
|
|
137
150
|
if(watcher_data->loop == Qnil)
|
|
138
151
|
rb_raise(rb_eRuntimeError, "not attached to a loop");
|
|
@@ -155,7 +168,7 @@ static VALUE Coolio_Watcher_detach(VALUE self)
|
|
|
155
168
|
|
|
156
169
|
watcher_data->enabled = 0;
|
|
157
170
|
|
|
158
|
-
|
|
171
|
+
loop_data = Coolio_Loop_ptr(watcher_data->loop);
|
|
159
172
|
|
|
160
173
|
/* Iterate through the events in the loop's event buffer. If there
|
|
161
174
|
* are any pending events from this watcher, mark them NULL. The
|
|
@@ -182,7 +195,7 @@ static VALUE Coolio_Watcher_detach(VALUE self)
|
|
|
182
195
|
static VALUE Coolio_Watcher_enable(VALUE self)
|
|
183
196
|
{
|
|
184
197
|
struct Coolio_Watcher *watcher_data;
|
|
185
|
-
|
|
198
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
186
199
|
|
|
187
200
|
if(watcher_data->enabled)
|
|
188
201
|
rb_raise(rb_eRuntimeError, "already enabled");
|
|
@@ -208,7 +221,7 @@ static VALUE Coolio_Watcher_enable(VALUE self)
|
|
|
208
221
|
static VALUE Coolio_Watcher_disable(VALUE self)
|
|
209
222
|
{
|
|
210
223
|
struct Coolio_Watcher *watcher_data;
|
|
211
|
-
|
|
224
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
212
225
|
|
|
213
226
|
if(!watcher_data->enabled)
|
|
214
227
|
rb_raise(rb_eRuntimeError, "already disabled");
|
|
@@ -234,7 +247,7 @@ static VALUE Coolio_Watcher_evloop(VALUE self)
|
|
|
234
247
|
{
|
|
235
248
|
struct Coolio_Watcher *watcher_data;
|
|
236
249
|
|
|
237
|
-
|
|
250
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
238
251
|
return watcher_data->loop;
|
|
239
252
|
}
|
|
240
253
|
|
|
@@ -258,7 +271,7 @@ static VALUE Coolio_Watcher_attached(VALUE self)
|
|
|
258
271
|
static VALUE Coolio_Watcher_enabled(VALUE self)
|
|
259
272
|
{
|
|
260
273
|
struct Coolio_Watcher *watcher_data;
|
|
261
|
-
|
|
274
|
+
watcher_data = Coolio_Watcher_ptr(self);
|
|
262
275
|
|
|
263
276
|
return watcher_data->enabled ? Qtrue : Qfalse;
|
|
264
277
|
}
|
data/ext/cool.io/watcher.h
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
if(!rb_obj_is_kind_of(loop, cCoolio_Loop)) \
|
|
15
15
|
rb_raise(rb_eArgError, "expected loop to be an instance of Coolio::Loop, not %s", RSTRING_PTR(rb_inspect(loop))); \
|
|
16
16
|
\
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
watcher_data = Coolio_Watcher_ptr(watcher); \
|
|
18
|
+
loop_data = Coolio_Loop_ptr(loop); \
|
|
19
19
|
\
|
|
20
20
|
if(watcher_data->loop != Qnil) \
|
|
21
21
|
detach_func(watcher); \
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
struct Coolio_Watcher *watcher_data; \
|
|
29
29
|
struct Coolio_Loop *loop_data; \
|
|
30
30
|
\
|
|
31
|
-
|
|
31
|
+
watcher_data = Coolio_Watcher_ptr(watcher); \
|
|
32
32
|
\
|
|
33
33
|
if(watcher_data->loop == Qnil) \
|
|
34
34
|
rb_raise(rb_eRuntimeError, "not attached to a loop"); \
|
|
35
35
|
\
|
|
36
|
-
|
|
36
|
+
loop_data = Coolio_Loop_ptr(watcher_data->loop); \
|
|
37
37
|
\
|
|
38
38
|
ev_##watcher_type##_stop(loop_data->ev_loop, &watcher_data->event_types.ev_##watcher_type); \
|
|
39
39
|
rb_call_super(0, 0)
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
struct Coolio_Watcher *watcher_data; \
|
|
43
43
|
struct Coolio_Loop *loop_data; \
|
|
44
44
|
\
|
|
45
|
-
|
|
45
|
+
watcher_data = Coolio_Watcher_ptr(watcher); \
|
|
46
46
|
\
|
|
47
47
|
if(watcher_data->loop == Qnil) \
|
|
48
48
|
rb_raise(rb_eRuntimeError, "not attached to a loop"); \
|
|
49
49
|
\
|
|
50
50
|
rb_call_super(0, 0); \
|
|
51
51
|
\
|
|
52
|
-
|
|
52
|
+
loop_data = Coolio_Loop_ptr(watcher_data->loop); \
|
|
53
53
|
\
|
|
54
54
|
ev_##watcher_type##_start(loop_data->ev_loop, &watcher_data->event_types.ev_##watcher_type)
|
|
55
55
|
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
struct Coolio_Watcher *watcher_data; \
|
|
58
58
|
struct Coolio_Loop *loop_data; \
|
|
59
59
|
\
|
|
60
|
-
|
|
60
|
+
watcher_data = Coolio_Watcher_ptr(watcher); \
|
|
61
61
|
\
|
|
62
62
|
if(watcher_data->loop == Qnil) \
|
|
63
63
|
rb_raise(rb_eRuntimeError, "not attached to a loop"); \
|
|
64
64
|
\
|
|
65
65
|
rb_call_super(0, 0); \
|
|
66
66
|
\
|
|
67
|
-
|
|
67
|
+
loop_data = Coolio_Loop_ptr(watcher_data->loop); \
|
|
68
68
|
\
|
|
69
69
|
ev_##watcher_type##_stop(loop_data->ev_loop, &watcher_data->event_types.ev_##watcher_type)
|
|
70
70
|
|
data/{Gemfile → gems.rb}
RENAMED
data/lib/cool.io/dns_resolver.rb
CHANGED
|
@@ -72,7 +72,7 @@ module Coolio
|
|
|
72
72
|
raise RuntimeError, "no nameservers found" if nameservers.empty? # TODO just call resolve_failed, not raise [also handle Errno::ENOENT)]
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
@nameservers = nameservers
|
|
75
|
+
@nameservers = nameservers.dup
|
|
76
76
|
@question = request_question hostname
|
|
77
77
|
|
|
78
78
|
@socket = UDPSocket.new
|
data/lib/cool.io/io.rb
CHANGED
data/lib/cool.io/socket.rb
CHANGED
|
@@ -130,7 +130,7 @@ module Coolio
|
|
|
130
130
|
|
|
131
131
|
# Called by precreate during asyncronous DNS resolution
|
|
132
132
|
def preinitialize(addr, port, *args)
|
|
133
|
-
@_write_buffer = ::
|
|
133
|
+
@_write_buffer = ::Coolio::Buffer.new # allow for writing BEFORE DNS has resolved
|
|
134
134
|
@remote_host, @remote_addr, @remote_port = addr, addr, port
|
|
135
135
|
@_resolver = TCPConnectResolver.new(self, addr, port, *args)
|
|
136
136
|
end
|
data/lib/cool.io/version.rb
CHANGED
data/lib/cool.io.rb
CHANGED
data/spec/iobuffer_spec.rb
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cool.io
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tony Arcieri
|
|
8
8
|
- Masahiro Nakagawa
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: rake-compiler
|
|
@@ -75,15 +74,12 @@ email:
|
|
|
75
74
|
executables: []
|
|
76
75
|
extensions:
|
|
77
76
|
- ext/cool.io/extconf.rb
|
|
78
|
-
- ext/iobuffer/extconf.rb
|
|
79
77
|
extra_rdoc_files: []
|
|
80
78
|
files:
|
|
81
79
|
- ".github/workflows/test.yaml"
|
|
82
80
|
- ".gitignore"
|
|
83
81
|
- ".rspec"
|
|
84
|
-
- ".travis.yml"
|
|
85
82
|
- CHANGES.md
|
|
86
|
-
- Gemfile
|
|
87
83
|
- LICENSE
|
|
88
84
|
- README.md
|
|
89
85
|
- Rakefile
|
|
@@ -96,6 +92,7 @@ files:
|
|
|
96
92
|
- examples/echo_server.rb
|
|
97
93
|
- examples/google.rb
|
|
98
94
|
- ext/cool.io/.gitignore
|
|
95
|
+
- ext/cool.io/buffer.c
|
|
99
96
|
- ext/cool.io/cool.io.h
|
|
100
97
|
- ext/cool.io/cool.io_ext.c
|
|
101
98
|
- ext/cool.io/ev_wrap.h
|
|
@@ -108,8 +105,6 @@ files:
|
|
|
108
105
|
- ext/cool.io/utils.c
|
|
109
106
|
- ext/cool.io/watcher.c
|
|
110
107
|
- ext/cool.io/watcher.h
|
|
111
|
-
- ext/iobuffer/extconf.rb
|
|
112
|
-
- ext/iobuffer/iobuffer.c
|
|
113
108
|
- ext/libev/Changes
|
|
114
109
|
- ext/libev/LICENSE
|
|
115
110
|
- ext/libev/README
|
|
@@ -125,6 +120,7 @@ files:
|
|
|
125
120
|
- ext/libev/ev_win32.c
|
|
126
121
|
- ext/libev/ev_wrap.h
|
|
127
122
|
- ext/libev/test_libev_win32.c
|
|
123
|
+
- gems.rb
|
|
128
124
|
- lib/.gitignore
|
|
129
125
|
- lib/cool.io.rb
|
|
130
126
|
- lib/cool.io/async_watcher.rb
|
|
@@ -158,7 +154,6 @@ homepage: https://github.com/socketry/cool.io
|
|
|
158
154
|
licenses:
|
|
159
155
|
- MIT
|
|
160
156
|
metadata: {}
|
|
161
|
-
post_install_message:
|
|
162
157
|
rdoc_options: []
|
|
163
158
|
require_paths:
|
|
164
159
|
- lib
|
|
@@ -173,8 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
173
168
|
- !ruby/object:Gem::Version
|
|
174
169
|
version: '0'
|
|
175
170
|
requirements: []
|
|
176
|
-
rubygems_version:
|
|
177
|
-
signing_key:
|
|
171
|
+
rubygems_version: 4.0.0.dev
|
|
178
172
|
specification_version: 4
|
|
179
173
|
summary: A cool framework for doing high performance I/O in Ruby
|
|
180
174
|
test_files:
|
data/.travis.yml
DELETED
data/ext/iobuffer/extconf.rb
DELETED