nio4r 2.5.8 → 2.7.4
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
- checksums.yaml.gz.sig +0 -0
- data/{CHANGES.md → changes.md} +48 -0
- data/ext/nio4r/bytebuffer.c +75 -38
- data/ext/nio4r/extconf.rb +19 -1
- data/ext/nio4r/monitor.c +47 -22
- data/ext/nio4r/nio4r.h +1 -5
- data/ext/nio4r/nio4r_ext.c +4 -0
- data/ext/nio4r/org/nio4r/ByteBuffer.java +1 -1
- data/ext/nio4r/org/nio4r/Monitor.java +2 -2
- data/ext/nio4r/org/nio4r/Selector.java +2 -2
- data/ext/nio4r/selector.c +72 -48
- data/lib/nio/bytebuffer.rb +6 -0
- data/lib/nio/monitor.rb +7 -0
- data/lib/nio/selector.rb +15 -0
- data/lib/nio/version.rb +6 -1
- data/lib/nio.rb +9 -0
- data/lib/nio4r.rb +7 -0
- data/license.md +80 -0
- data/readme.md +91 -0
- data.tar.gz.sig +3 -0
- metadata +96 -75
- metadata.gz.sig +0 -0
- data/.github/workflows/workflow.yml +0 -47
- data/.gitignore +0 -21
- data/.rspec +0 -4
- data/.rubocop.yml +0 -100
- data/Gemfile +0 -18
- data/README.md +0 -133
- data/Rakefile +0 -8
- data/examples/echo_server.rb +0 -47
- data/logo.png +0 -0
- data/nio4r.gemspec +0 -42
- data/rakelib/extension.rake +0 -15
- data/rakelib/rspec.rake +0 -9
- data/rakelib/rubocop.rake +0 -5
- data/spec/nio/acceptables_spec.rb +0 -32
- data/spec/nio/bytebuffer_spec.rb +0 -354
- data/spec/nio/monitor_spec.rb +0 -162
- data/spec/nio/selectables/pipe_spec.rb +0 -47
- data/spec/nio/selectables/ssl_socket_spec.rb +0 -194
- data/spec/nio/selectables/tcp_socket_spec.rb +0 -101
- data/spec/nio/selectables/udp_socket_spec.rb +0 -48
- data/spec/nio/selector_spec.rb +0 -240
- data/spec/spec_helper.rb +0 -20
- data/spec/support/selectable_examples.rb +0 -85
data/ext/nio4r/selector.c
CHANGED
@@ -23,9 +23,10 @@ static VALUE cNIO_Selector = Qnil;
|
|
23
23
|
|
24
24
|
/* Allocator/deallocator */
|
25
25
|
static VALUE NIO_Selector_allocate(VALUE klass);
|
26
|
-
static void NIO_Selector_mark(
|
26
|
+
static void NIO_Selector_mark(void *data);
|
27
27
|
static void NIO_Selector_shutdown(struct NIO_Selector *selector);
|
28
|
-
static void NIO_Selector_free(
|
28
|
+
static void NIO_Selector_free(void *data);
|
29
|
+
static size_t NIO_Selector_memsize(const void *data);
|
29
30
|
|
30
31
|
/* Class methods */
|
31
32
|
static VALUE NIO_Selector_supported_backends(VALUE klass);
|
@@ -43,13 +44,13 @@ static VALUE NIO_Selector_closed(VALUE self);
|
|
43
44
|
static VALUE NIO_Selector_is_empty(VALUE self);
|
44
45
|
|
45
46
|
/* Internal functions */
|
46
|
-
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE
|
47
|
+
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE arg), VALUE arg);
|
47
48
|
static VALUE NIO_Selector_unlock(VALUE lock);
|
48
|
-
static VALUE NIO_Selector_register_synchronized(VALUE
|
49
|
-
static VALUE NIO_Selector_deregister_synchronized(VALUE
|
50
|
-
static VALUE NIO_Selector_select_synchronized(VALUE
|
51
|
-
static VALUE NIO_Selector_close_synchronized(VALUE
|
52
|
-
static VALUE NIO_Selector_closed_synchronized(VALUE
|
49
|
+
static VALUE NIO_Selector_register_synchronized(VALUE arg);
|
50
|
+
static VALUE NIO_Selector_deregister_synchronized(VALUE arg);
|
51
|
+
static VALUE NIO_Selector_select_synchronized(VALUE arg);
|
52
|
+
static VALUE NIO_Selector_close_synchronized(VALUE arg);
|
53
|
+
static VALUE NIO_Selector_closed_synchronized(VALUE arg);
|
53
54
|
|
54
55
|
static int NIO_Selector_run(struct NIO_Selector *selector, VALUE timeout);
|
55
56
|
static void NIO_Selector_timeout_callback(struct ev_loop *ev_loop, struct ev_timer *timer, int revents);
|
@@ -62,7 +63,7 @@ static void NIO_Selector_wakeup_callback(struct ev_loop *ev_loop, struct ev_io *
|
|
62
63
|
#define BUSYWAIT_INTERVAL 0.01
|
63
64
|
|
64
65
|
/* Selectors wait for events */
|
65
|
-
void Init_NIO_Selector()
|
66
|
+
void Init_NIO_Selector(void)
|
66
67
|
{
|
67
68
|
mNIO = rb_define_module("NIO");
|
68
69
|
cNIO_Selector = rb_define_class_under(mNIO, "Selector", rb_cObject);
|
@@ -83,6 +84,18 @@ void Init_NIO_Selector()
|
|
83
84
|
cNIO_Monitor = rb_define_class_under(mNIO, "Monitor", rb_cObject);
|
84
85
|
}
|
85
86
|
|
87
|
+
static const rb_data_type_t NIO_Selector_type = {
|
88
|
+
"NIO::Selector",
|
89
|
+
{
|
90
|
+
NIO_Selector_mark,
|
91
|
+
NIO_Selector_free,
|
92
|
+
NIO_Selector_memsize,
|
93
|
+
},
|
94
|
+
0,
|
95
|
+
0,
|
96
|
+
RUBY_TYPED_WB_PROTECTED // Don't free immediately because of shutdown
|
97
|
+
};
|
98
|
+
|
86
99
|
/* Create the libev event loop and incoming event buffer */
|
87
100
|
static VALUE NIO_Selector_allocate(VALUE klass)
|
88
101
|
{
|
@@ -104,8 +117,7 @@ static VALUE NIO_Selector_allocate(VALUE klass)
|
|
104
117
|
rb_sys_fail("fcntl");
|
105
118
|
}
|
106
119
|
|
107
|
-
|
108
|
-
|
120
|
+
VALUE obj = TypedData_Make_Struct(klass, struct NIO_Selector, &NIO_Selector_type, selector);
|
109
121
|
/* Defer initializing the loop to #initialize */
|
110
122
|
selector->ev_loop = 0;
|
111
123
|
|
@@ -118,14 +130,21 @@ static VALUE NIO_Selector_allocate(VALUE klass)
|
|
118
130
|
selector->wakeup.data = (void *)selector;
|
119
131
|
|
120
132
|
selector->closed = selector->selecting = selector->wakeup_fired = selector->ready_count = 0;
|
121
|
-
selector->ready_array
|
133
|
+
RB_OBJ_WRITE(obj, &selector->ready_array, Qnil);
|
134
|
+
return obj;
|
135
|
+
}
|
122
136
|
|
123
|
-
|
137
|
+
struct NIO_Selector *NIO_Selector_unwrap(VALUE self)
|
138
|
+
{
|
139
|
+
struct NIO_Selector *selector;
|
140
|
+
TypedData_Get_Struct(self, struct NIO_Selector, &NIO_Selector_type, selector);
|
141
|
+
return selector;
|
124
142
|
}
|
125
143
|
|
126
144
|
/* NIO selectors store all Ruby objects in instance variables so mark is a stub */
|
127
|
-
static void NIO_Selector_mark(
|
145
|
+
static void NIO_Selector_mark(void *data)
|
128
146
|
{
|
147
|
+
struct NIO_Selector *selector = (struct NIO_Selector *)data;
|
129
148
|
if (selector->ready_array != Qnil) {
|
130
149
|
rb_gc_mark(selector->ready_array);
|
131
150
|
}
|
@@ -151,12 +170,18 @@ static void NIO_Selector_shutdown(struct NIO_Selector *selector)
|
|
151
170
|
}
|
152
171
|
|
153
172
|
/* Ruby finalizer for selector objects */
|
154
|
-
static void NIO_Selector_free(
|
173
|
+
static void NIO_Selector_free(void *data)
|
155
174
|
{
|
175
|
+
struct NIO_Selector *selector = (struct NIO_Selector *)data;
|
156
176
|
NIO_Selector_shutdown(selector);
|
157
177
|
xfree(selector);
|
158
178
|
}
|
159
179
|
|
180
|
+
static size_t NIO_Selector_memsize(const void *data)
|
181
|
+
{
|
182
|
+
return sizeof(struct NIO_Selector);
|
183
|
+
}
|
184
|
+
|
160
185
|
/* Return an array of symbols for supported backends */
|
161
186
|
static VALUE NIO_Selector_supported_backends(VALUE klass)
|
162
187
|
{
|
@@ -205,7 +230,7 @@ static VALUE NIO_Selector_initialize(int argc, VALUE *argv, VALUE self)
|
|
205
230
|
struct NIO_Selector *selector;
|
206
231
|
unsigned int flags = 0;
|
207
232
|
|
208
|
-
|
233
|
+
TypedData_Get_Struct(self, struct NIO_Selector, &NIO_Selector_type, selector);
|
209
234
|
|
210
235
|
rb_scan_args(argc, argv, "01", &backend);
|
211
236
|
|
@@ -259,7 +284,7 @@ static VALUE NIO_Selector_backend(VALUE self)
|
|
259
284
|
{
|
260
285
|
struct NIO_Selector *selector;
|
261
286
|
|
262
|
-
|
287
|
+
TypedData_Get_Struct(self, struct NIO_Selector, &NIO_Selector_type, selector);
|
263
288
|
if (selector->closed) {
|
264
289
|
rb_raise(rb_eIOError, "selector is closed");
|
265
290
|
}
|
@@ -285,7 +310,7 @@ static VALUE NIO_Selector_backend(VALUE self)
|
|
285
310
|
}
|
286
311
|
|
287
312
|
/* Synchronize around a reentrant selector lock */
|
288
|
-
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE
|
313
|
+
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE arg), VALUE arg)
|
289
314
|
{
|
290
315
|
VALUE current_thread, lock_holder, lock;
|
291
316
|
|
@@ -298,10 +323,10 @@ static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VA
|
|
298
323
|
rb_ivar_set(self, rb_intern("lock_holder"), current_thread);
|
299
324
|
|
300
325
|
/* We've acquired the lock, so ensure we unlock it */
|
301
|
-
return rb_ensure(func, (VALUE)
|
326
|
+
return rb_ensure(func, (VALUE)arg, NIO_Selector_unlock, self);
|
302
327
|
} else {
|
303
328
|
/* We already hold the selector lock, so no need to unlock it */
|
304
|
-
return func(
|
329
|
+
return func(arg);
|
305
330
|
}
|
306
331
|
}
|
307
332
|
|
@@ -321,22 +346,23 @@ static VALUE NIO_Selector_unlock(VALUE self)
|
|
321
346
|
/* Register an IO object with the selector for the given interests */
|
322
347
|
static VALUE NIO_Selector_register(VALUE self, VALUE io, VALUE interests)
|
323
348
|
{
|
324
|
-
VALUE args[3] = {
|
325
|
-
return NIO_Selector_synchronize(self, NIO_Selector_register_synchronized, args);
|
349
|
+
VALUE args[3] = {self, io, interests};
|
350
|
+
return NIO_Selector_synchronize(self, NIO_Selector_register_synchronized, (VALUE)args);
|
326
351
|
}
|
327
352
|
|
328
353
|
/* Internal implementation of register after acquiring mutex */
|
329
|
-
static VALUE NIO_Selector_register_synchronized(VALUE
|
354
|
+
static VALUE NIO_Selector_register_synchronized(VALUE _args)
|
330
355
|
{
|
331
356
|
VALUE self, io, interests, selectables, monitor;
|
332
357
|
VALUE monitor_args[3];
|
333
358
|
struct NIO_Selector *selector;
|
334
359
|
|
360
|
+
VALUE *args = (VALUE *)_args;
|
335
361
|
self = args[0];
|
336
362
|
io = args[1];
|
337
363
|
interests = args[2];
|
338
364
|
|
339
|
-
|
365
|
+
TypedData_Get_Struct(self, struct NIO_Selector, &NIO_Selector_type, selector);
|
340
366
|
if (selector->closed) {
|
341
367
|
rb_raise(rb_eIOError, "selector is closed");
|
342
368
|
}
|
@@ -361,15 +387,16 @@ static VALUE NIO_Selector_register_synchronized(VALUE *args)
|
|
361
387
|
/* Deregister an IO object from the selector */
|
362
388
|
static VALUE NIO_Selector_deregister(VALUE self, VALUE io)
|
363
389
|
{
|
364
|
-
VALUE args[2] = {
|
365
|
-
return NIO_Selector_synchronize(self, NIO_Selector_deregister_synchronized, args);
|
390
|
+
VALUE args[2] = {self, io};
|
391
|
+
return NIO_Selector_synchronize(self, NIO_Selector_deregister_synchronized, (VALUE)args);
|
366
392
|
}
|
367
393
|
|
368
394
|
/* Internal implementation of register after acquiring mutex */
|
369
|
-
static VALUE NIO_Selector_deregister_synchronized(VALUE
|
395
|
+
static VALUE NIO_Selector_deregister_synchronized(VALUE _args)
|
370
396
|
{
|
371
397
|
VALUE self, io, selectables, monitor;
|
372
398
|
|
399
|
+
VALUE *args = (VALUE *)_args;
|
373
400
|
self = args[0];
|
374
401
|
io = args[1];
|
375
402
|
|
@@ -396,7 +423,6 @@ static VALUE NIO_Selector_is_registered(VALUE self, VALUE io)
|
|
396
423
|
static VALUE NIO_Selector_select(int argc, VALUE *argv, VALUE self)
|
397
424
|
{
|
398
425
|
VALUE timeout;
|
399
|
-
VALUE args[2];
|
400
426
|
|
401
427
|
rb_scan_args(argc, argv, "01", &timeout);
|
402
428
|
|
@@ -404,27 +430,27 @@ static VALUE NIO_Selector_select(int argc, VALUE *argv, VALUE self)
|
|
404
430
|
rb_raise(rb_eArgError, "time interval must be positive");
|
405
431
|
}
|
406
432
|
|
407
|
-
args[
|
408
|
-
|
409
|
-
|
410
|
-
return NIO_Selector_synchronize(self, NIO_Selector_select_synchronized, args);
|
433
|
+
VALUE args[2] = {self, timeout};
|
434
|
+
return NIO_Selector_synchronize(self, NIO_Selector_select_synchronized, (VALUE)args);
|
411
435
|
}
|
412
436
|
|
413
437
|
/* Internal implementation of select with the selector lock held */
|
414
|
-
static VALUE NIO_Selector_select_synchronized(VALUE
|
438
|
+
static VALUE NIO_Selector_select_synchronized(VALUE _args)
|
415
439
|
{
|
416
440
|
int ready;
|
417
441
|
VALUE ready_array;
|
418
442
|
struct NIO_Selector *selector;
|
419
443
|
|
420
|
-
|
444
|
+
VALUE *args = (VALUE *)_args;
|
445
|
+
|
446
|
+
TypedData_Get_Struct(args[0], struct NIO_Selector, &NIO_Selector_type, selector);
|
421
447
|
|
422
448
|
if (selector->closed) {
|
423
449
|
rb_raise(rb_eIOError, "selector is closed");
|
424
450
|
}
|
425
451
|
|
426
452
|
if (!rb_block_given_p()) {
|
427
|
-
selector->ready_array
|
453
|
+
RB_OBJ_WRITE(args[0], &selector->ready_array, rb_ary_new());
|
428
454
|
}
|
429
455
|
|
430
456
|
ready = NIO_Selector_run(selector, args[1]);
|
@@ -432,7 +458,7 @@ static VALUE NIO_Selector_select_synchronized(VALUE *args)
|
|
432
458
|
/* Timeout */
|
433
459
|
if (ready < 0) {
|
434
460
|
if (!rb_block_given_p()) {
|
435
|
-
selector->ready_array
|
461
|
+
RB_OBJ_WRITE(args[0], &selector->ready_array, Qnil);
|
436
462
|
}
|
437
463
|
|
438
464
|
return Qnil;
|
@@ -442,7 +468,7 @@ static VALUE NIO_Selector_select_synchronized(VALUE *args)
|
|
442
468
|
return INT2NUM(ready);
|
443
469
|
} else {
|
444
470
|
ready_array = selector->ready_array;
|
445
|
-
selector->ready_array
|
471
|
+
RB_OBJ_WRITE(args[0], &selector->ready_array, Qnil);
|
446
472
|
return ready_array;
|
447
473
|
}
|
448
474
|
}
|
@@ -489,7 +515,7 @@ static int NIO_Selector_run(struct NIO_Selector *selector, VALUE timeout)
|
|
489
515
|
static VALUE NIO_Selector_wakeup(VALUE self)
|
490
516
|
{
|
491
517
|
struct NIO_Selector *selector;
|
492
|
-
|
518
|
+
TypedData_Get_Struct(self, struct NIO_Selector, &NIO_Selector_type, selector);
|
493
519
|
|
494
520
|
if (selector->closed) {
|
495
521
|
rb_raise(rb_eIOError, "selector is closed");
|
@@ -504,15 +530,14 @@ static VALUE NIO_Selector_wakeup(VALUE self)
|
|
504
530
|
/* Close the selector and free system resources */
|
505
531
|
static VALUE NIO_Selector_close(VALUE self)
|
506
532
|
{
|
507
|
-
|
508
|
-
return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, args);
|
533
|
+
return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
|
509
534
|
}
|
510
535
|
|
511
|
-
static VALUE NIO_Selector_close_synchronized(VALUE
|
536
|
+
static VALUE NIO_Selector_close_synchronized(VALUE self)
|
512
537
|
{
|
513
538
|
struct NIO_Selector *selector;
|
514
|
-
|
515
|
-
|
539
|
+
|
540
|
+
TypedData_Get_Struct(self, struct NIO_Selector, &NIO_Selector_type, selector);
|
516
541
|
|
517
542
|
NIO_Selector_shutdown(selector);
|
518
543
|
|
@@ -522,15 +547,14 @@ static VALUE NIO_Selector_close_synchronized(VALUE *args)
|
|
522
547
|
/* Is the selector closed? */
|
523
548
|
static VALUE NIO_Selector_closed(VALUE self)
|
524
549
|
{
|
525
|
-
|
526
|
-
return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, args);
|
550
|
+
return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
|
527
551
|
}
|
528
552
|
|
529
|
-
static VALUE NIO_Selector_closed_synchronized(VALUE
|
553
|
+
static VALUE NIO_Selector_closed_synchronized(VALUE self)
|
530
554
|
{
|
531
555
|
struct NIO_Selector *selector;
|
532
|
-
|
533
|
-
|
556
|
+
|
557
|
+
TypedData_Get_Struct(self, struct NIO_Selector, &NIO_Selector_type, selector);
|
534
558
|
|
535
559
|
return selector->closed ? Qtrue : Qfalse;
|
536
560
|
}
|
data/lib/nio/bytebuffer.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016, by Upekshe Jayasekera.
|
5
|
+
# Copyright, 2016-2017, by Tony Arcieri.
|
6
|
+
# Copyright, 2020, by Thomas Dziedzic.
|
7
|
+
# Copyright, 2023, by Samuel Williams.
|
8
|
+
|
3
9
|
module NIO
|
4
10
|
# Efficient byte buffers for performant I/O operations
|
5
11
|
class ByteBuffer
|
data/lib/nio/monitor.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2011-2018, by Tony Arcieri.
|
5
|
+
# Copyright, 2015, by Upekshe Jayasekera.
|
6
|
+
# Copyright, 2015, by Vladimir Kochnev.
|
7
|
+
# Copyright, 2018-2023, by Samuel Williams.
|
8
|
+
# Copyright, 2019-2020, by Gregory Longtin.
|
9
|
+
|
3
10
|
module NIO
|
4
11
|
# Monitors watch IO objects for specific events
|
5
12
|
class Monitor
|
data/lib/nio/selector.rb
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2011-2017, by Tony Arcieri.
|
5
|
+
# Copyright, 2012, by Logan Bowers.
|
6
|
+
# Copyright, 2013, by Sadayuki Furuhashi.
|
7
|
+
# Copyright, 2013, by Stephen von Takach.
|
8
|
+
# Copyright, 2013, by Tim Carey-Smith.
|
9
|
+
# Copyright, 2013, by Ravil Bayramgalin.
|
10
|
+
# Copyright, 2014, by Sergey Avseyev.
|
11
|
+
# Copyright, 2014, by John Thornton.
|
12
|
+
# Copyright, 2015, by Vladimir Kochnev.
|
13
|
+
# Copyright, 2015, by Upekshe Jayasekera.
|
14
|
+
# Copyright, 2019-2020, by Gregory Longtin.
|
15
|
+
# Copyright, 2020-2021, by Joao Fernandes.
|
16
|
+
# Copyright, 2023, by Samuel Williams.
|
17
|
+
|
3
18
|
require "set"
|
4
19
|
|
5
20
|
module NIO
|
data/lib/nio/version.rb
CHANGED
data/lib/nio.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2011-2017, by Tony Arcieri.
|
5
|
+
# Copyright, 2013, by Stephen von Takach.
|
6
|
+
# Copyright, 2013, by Per Lundberg.
|
7
|
+
# Copyright, 2014, by Marek Kowalcze.
|
8
|
+
# Copyright, 2016, by Upekshe Jayasekera.
|
9
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
10
|
+
# Copyright, 2021, by Jun Jiang.
|
11
|
+
|
3
12
|
require "socket"
|
4
13
|
require "nio/version"
|
5
14
|
|
data/lib/nio4r.rb
ADDED
data/license.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2011-2020, by Tony Arcieri.
|
4
|
+
Copyright, 2012, by Bernd Ahlers.
|
5
|
+
Copyright, 2012, by Logan Bowers.
|
6
|
+
Copyright, 2012, by Dirkjan Bussink.
|
7
|
+
Copyright, 2013, by Sadayuki Furuhashi.
|
8
|
+
Copyright, 2013, by Shannon Skipper.
|
9
|
+
Copyright, 2013, by Stephen von Takach.
|
10
|
+
Copyright, 2013, by Tim Carey-Smith.
|
11
|
+
Copyright, 2013, by Per Lundberg.
|
12
|
+
Copyright, 2013, by Ravil Bayramgalin.
|
13
|
+
Copyright, 2013, by Luis Lavena.
|
14
|
+
Copyright, 2014, by Anatol Pomozov.
|
15
|
+
Copyright, 2014, by Hiroshi Shibata.
|
16
|
+
Copyright, 2014, by Marek Kowalcze.
|
17
|
+
Copyright, 2014, by Sergey Avseyev.
|
18
|
+
Copyright, 2014, by John Thornton.
|
19
|
+
Copyright, 2015-2017, by Tiago Cardoso.
|
20
|
+
Copyright, 2015, by Daniel Berger.
|
21
|
+
Copyright, 2015-2016, by Upekshe Jayasekera.
|
22
|
+
Copyright, 2015, by Vladimir Kochnev.
|
23
|
+
Copyright, 2016-2018, by Jun Aruga.
|
24
|
+
Copyright, 2016, by Omer Katz.
|
25
|
+
Copyright, 2016, by Denis Washington.
|
26
|
+
Copyright, 2016-2021, by Olle Jonsson.
|
27
|
+
Copyright, 2017, by Tao Luo.
|
28
|
+
Copyright, 2017, by Usaku Nakamura.
|
29
|
+
Copyright, 2017-2022, by Gregory Longtin.
|
30
|
+
Copyright, 2017, by Lars Kanis.
|
31
|
+
Copyright, 2017, by Tomoya Ishida.
|
32
|
+
Copyright, 2018-2024, by Samuel Williams.
|
33
|
+
Copyright, 2019, by Cédric Boutillier.
|
34
|
+
Copyright, 2019-2020, by Benoit Daloze.
|
35
|
+
Copyright, 2019, by Jesús Burgos Maciá.
|
36
|
+
Copyright, 2019, by Thomas Kuntz.
|
37
|
+
Copyright, 2019, by Orien Madgwick.
|
38
|
+
Copyright, 2019, by Zhang Kang.
|
39
|
+
Copyright, 2020, by Thomas Dziedzic.
|
40
|
+
Copyright, 2020, by Elad Eyal.
|
41
|
+
Copyright, 2020, by Pedro Paiva.
|
42
|
+
Copyright, 2020, by Boaz Segev.
|
43
|
+
Copyright, 2020, by Charles Oliver Nutter.
|
44
|
+
Copyright, 2020-2021, by Joao Fernandes.
|
45
|
+
Copyright, 2021, by Jun Jiang.
|
46
|
+
Copyright, 2021, by Pavel Lobashov.
|
47
|
+
Copyright, 2021, by Jeffrey Martin.
|
48
|
+
Copyright, 2023-2024, by Pavel Rosický.
|
49
|
+
Copyright, 2023, by Tsimnuj Hawj.
|
50
|
+
Copyright, 2023, by Phillip Aldridge.
|
51
|
+
Copyright, 2023, by Maxime Demolin.
|
52
|
+
Copyright, 2023-2024, by Vít Ondruch.
|
53
|
+
Copyright, 2023, by Jean Boussier.
|
54
|
+
|
55
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
56
|
+
of this software and associated documentation files (the "Software"), to deal
|
57
|
+
in the Software without restriction, including without limitation the rights
|
58
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
59
|
+
copies of the Software, and to permit persons to whom the Software is
|
60
|
+
furnished to do so, subject to the following conditions:
|
61
|
+
|
62
|
+
The above copyright notice and this permission notice shall be included in all
|
63
|
+
copies or substantial portions of the Software.
|
64
|
+
|
65
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
66
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
67
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
68
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
69
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
70
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
71
|
+
SOFTWARE.
|
72
|
+
|
73
|
+
## libev
|
74
|
+
|
75
|
+
Released under the BSD-2-Clause OR GPL-2.0-or-later license.
|
76
|
+
See [ext/libev/LICENSE] for details.
|
77
|
+
|
78
|
+
Copyright, 2007-2019, by Marc Alexander Lehmann.
|
79
|
+
|
80
|
+
[ext/libev/LICENSE]: https://github.com/socketry/nio4r/blob/master/ext/libev/LICENSE
|
data/readme.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# 
|
2
|
+
|
3
|
+
[](https://github.com/socketry/nio4r/actions?workflow=Test)
|
4
|
+
|
5
|
+
**New I/O for Ruby (nio4r)**: cross-platform asynchronous I/O primitives for
|
6
|
+
scalable network clients and servers. Modeled after the Java NIO API, but
|
7
|
+
simplified for ease-of-use.
|
8
|
+
|
9
|
+
**nio4r** provides an abstract, cross-platform stateful I/O selector API for Ruby.
|
10
|
+
I/O selectors are the heart of "reactor"-based event loops, and monitor
|
11
|
+
multiple I/O objects for various types of readiness, e.g. ready for reading or
|
12
|
+
writing.
|
13
|
+
|
14
|
+
## Projects using nio4r
|
15
|
+
|
16
|
+
- [ActionCable](https://rubygems.org/gems/actioncable): Rails 5 WebSocket protocol, uses nio4r for a WebSocket server
|
17
|
+
- [Celluloid](https://github.com/celluloid/celluloid-io): Actor-based concurrency framework, uses nio4r for async I/O
|
18
|
+
- [Async](https://github.com/socketry/async): Asynchronous I/O framework for Ruby
|
19
|
+
- [Puma](https://github.com/puma/puma): Ruby/Rack web server built for concurrency
|
20
|
+
|
21
|
+
## Goals
|
22
|
+
|
23
|
+
- Expose high-level interfaces for stateful IO selectors
|
24
|
+
- Keep the API small to maximize both portability and performance across many
|
25
|
+
different OSes and Ruby VMs
|
26
|
+
- Provide inherently thread-safe facilities for working with IO objects
|
27
|
+
|
28
|
+
## Supported platforms
|
29
|
+
|
30
|
+
- Ruby 2.5
|
31
|
+
- Ruby 2.6
|
32
|
+
- Ruby 2.7
|
33
|
+
- Ruby 3.0
|
34
|
+
- [JRuby](https://github.com/jruby/jruby)
|
35
|
+
- [TruffleRuby](https://github.com/oracle/truffleruby)
|
36
|
+
|
37
|
+
## Supported backends
|
38
|
+
|
39
|
+
- **libev**: MRI C extension targeting multiple native IO selector APIs (e.g epoll, kqueue)
|
40
|
+
- **Java NIO**: JRuby extension which wraps the Java NIO subsystem
|
41
|
+
- **Pure Ruby**: `Kernel.select`-based backend that should work on any Ruby interpreter
|
42
|
+
|
43
|
+
## Documentation
|
44
|
+
|
45
|
+
[Please see the nio4r wiki](https://github.com/socketry/nio4r/wiki)
|
46
|
+
for more detailed documentation and usage notes:
|
47
|
+
|
48
|
+
- [Getting Started](https://github.com/socketry/nio4r/wiki/Getting-Started): Introduction to nio4r's components
|
49
|
+
- [Selectors](https://github.com/socketry/nio4r/wiki/Selectors): monitor multiple `IO` objects for readiness events
|
50
|
+
- [Monitors](https://github.com/socketry/nio4r/wiki/Monitors): control interests and inspect readiness for specific `IO` objects
|
51
|
+
- [Byte Buffers](https://github.com/socketry/nio4r/wiki/Byte-Buffers): fixed-size native buffers for high-performance I/O
|
52
|
+
|
53
|
+
See also:
|
54
|
+
|
55
|
+
- [YARD API documentation](http://www.rubydoc.info/gems/nio4r/frames)
|
56
|
+
|
57
|
+
## Non-goals
|
58
|
+
|
59
|
+
**nio4r** is not a full-featured event framework like [EventMachine](https://github.com/eventmachine/eventmachine) or [Cool.io](https://coolio.github.io/).
|
60
|
+
Instead, nio4r is the sort of thing you might write a library like that on
|
61
|
+
top of. nio4r provides a minimal API such that individual Ruby implementers
|
62
|
+
may choose to produce optimized versions for their platform, without having
|
63
|
+
to maintain a large codebase.
|
64
|
+
|
65
|
+
## Releases
|
66
|
+
|
67
|
+
Bump the version first:
|
68
|
+
|
69
|
+
bundle exec bake gem:release:version:patch
|
70
|
+
|
71
|
+
### CRuby
|
72
|
+
|
73
|
+
rake clean
|
74
|
+
rake release
|
75
|
+
|
76
|
+
### JRuby
|
77
|
+
|
78
|
+
You might need to delete `Gemfile.lock` before trying to `bundle install`.
|
79
|
+
|
80
|
+
# Ensure you have the correct JDK:
|
81
|
+
pacman -Syu jdk-openjdk
|
82
|
+
archlinux-java set java-19-openjdk
|
83
|
+
|
84
|
+
# Ensure you are using jruby:
|
85
|
+
chruby jruby
|
86
|
+
bundle update
|
87
|
+
|
88
|
+
# Build the package:
|
89
|
+
rake clean
|
90
|
+
rake compile
|
91
|
+
rake release
|
data.tar.gz.sig
ADDED