nio4r 2.5.9-java → 2.6.1-java
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/.mailmap +16 -0
- data/Gemfile +3 -2
- data/{CHANGES.md → changes.md} +4 -0
- data/examples/echo_server.rb +7 -0
- data/ext/nio4r/bytebuffer.c +29 -10
- data/ext/nio4r/extconf.rb +15 -0
- data/ext/nio4r/monitor.c +16 -5
- data/ext/nio4r/nio4r.h +0 -6
- 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 +5 -0
- data/lib/nio4r_ext.jar +0 -0
- data/license.md +48 -38
- data/nio4r.gemspec +2 -1
- data/readme.md +91 -0
- data/spec/nio/acceptables_spec.rb +4 -0
- data/spec/nio/bytebuffer_spec.rb +6 -0
- data/spec/nio/monitor_spec.rb +7 -0
- data/spec/nio/selectables/pipe_spec.rb +6 -0
- data/spec/nio/selectables/ssl_socket_spec.rb +7 -0
- data/spec/nio/selectables/tcp_socket_spec.rb +7 -0
- data/spec/nio/selectables/udp_socket_spec.rb +7 -0
- data/spec/nio/selector_spec.rb +12 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/selectable_examples.rb +8 -0
- metadata +9 -6
- data/README.md +0 -99
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cb403923227755e0bfecb7533b4b0005970d125005a9bb1af90457d4d1eaf7f
|
4
|
+
data.tar.gz: 4f25d3d22bef01576350fc6e6920fdf37b06cdbb506048265cff23813ca4f0ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12ffc05fa87e13a031e418ac2239bbd4d2a468c5af02b5637281f9ee22327d42b3cb62a650429e80cbdf1cd9bdff48e7b5fc412d6323c1187397ad7451722743
|
7
|
+
data.tar.gz: 898129e583351a7ed9fb041fc65741e595adba829ff71ba4260710ccacdf351175ffe771dab3df2b58c40f4289b6fa78917f4dcaa1f6444ee649dae2873f28a4
|
data/.mailmap
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Sadayuki Furuhashi <frsyuki@users.sourceforge.jp>
|
2
|
+
Shannon Skipper <shannonskipper@gmail.com>
|
3
|
+
Anatol Pomozov <anatol.pomozov@gmail.com>
|
4
|
+
Hiroshi Shibata <shibata.hiroshi@gmail.com>
|
5
|
+
John Thornton <ubergeek3141@gmail.com>
|
6
|
+
Upekshe Jayasekera <usmj000@gmail.com>
|
7
|
+
Upekshe Jayasekera <upekshej.11@cse.mrt.ac.lk>
|
8
|
+
Usaku Nakamura <usa@garbagecollect.jp>
|
9
|
+
Tomoya Ishida <tomoyapenguin@gmail.com>
|
10
|
+
Tiago Cardoso <cardoso_tiago@hotmail.com>
|
11
|
+
Ravil Bayramgalin <brainopia@evilmartians.com>
|
12
|
+
Gregory Longtin <Greg.mpls@gmail.com>
|
13
|
+
Gregory Longtin <Greg.mpls@gmail.com> <MSP-Greg@users.noreply.github.com>
|
14
|
+
Elad Eyal <elad.eyal@intel.com>
|
15
|
+
Boaz Segev <bo@bowild.com>
|
16
|
+
Tao Luo <luotao.ruby@gmail.com>
|
data/Gemfile
CHANGED
data/{CHANGES.md → changes.md}
RENAMED
data/examples/echo_server.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
# Released under the MIT License.
|
5
|
+
# Copyright, 2012-2016, by Tony Arcieri.
|
6
|
+
# Copyright, 2016, by Jun Aruga.
|
7
|
+
# Copyright, 2019, by Zhang Kang.
|
8
|
+
# Copyright, 2020, by Thomas Dziedzic.
|
9
|
+
# Copyright, 2023, by Samuel Williams.
|
10
|
+
|
4
11
|
$LOAD_PATH.push File.expand_path("../lib", __dir__)
|
5
12
|
require "nio"
|
6
13
|
require "socket"
|
data/ext/nio4r/bytebuffer.c
CHANGED
@@ -36,6 +36,26 @@ static VALUE NIO_ByteBuffer_inspect(VALUE self);
|
|
36
36
|
|
37
37
|
#define MARK_UNSET -1
|
38
38
|
|
39
|
+
/* Compatibility for Ruby <= 3.1 */
|
40
|
+
#ifndef HAVE_RB_IO_DESCRIPTOR
|
41
|
+
static int
|
42
|
+
io_descriptor_fallback(VALUE io)
|
43
|
+
{
|
44
|
+
rb_io_t *fptr;
|
45
|
+
GetOpenFile(io, fptr);
|
46
|
+
return fptr->fd;
|
47
|
+
}
|
48
|
+
#define rb_io_descriptor io_descriptor_fallback
|
49
|
+
#endif
|
50
|
+
|
51
|
+
static void
|
52
|
+
io_set_nonblock(VALUE io)
|
53
|
+
{
|
54
|
+
rb_io_t *fptr;
|
55
|
+
GetOpenFile(io, fptr);
|
56
|
+
rb_io_set_nonblock(fptr);
|
57
|
+
}
|
58
|
+
|
39
59
|
void Init_NIO_ByteBuffer()
|
40
60
|
{
|
41
61
|
mNIO = rb_define_module("NIO");
|
@@ -281,19 +301,19 @@ static VALUE NIO_ByteBuffer_put(VALUE self, VALUE string)
|
|
281
301
|
static VALUE NIO_ByteBuffer_read_from(VALUE self, VALUE io)
|
282
302
|
{
|
283
303
|
struct NIO_ByteBuffer *buffer;
|
284
|
-
rb_io_t *fptr;
|
285
304
|
ssize_t nbytes, bytes_read;
|
286
305
|
|
287
306
|
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
|
288
|
-
|
289
|
-
|
307
|
+
|
308
|
+
io = rb_convert_type(io, T_FILE, "IO", "to_io");
|
309
|
+
io_set_nonblock(io);
|
290
310
|
|
291
311
|
nbytes = buffer->limit - buffer->position;
|
292
312
|
if (nbytes == 0) {
|
293
313
|
rb_raise(cNIO_ByteBuffer_OverflowError, "buffer is full");
|
294
314
|
}
|
295
315
|
|
296
|
-
bytes_read = read(
|
316
|
+
bytes_read = read(rb_io_descriptor(io), buffer->buffer + buffer->position, nbytes);
|
297
317
|
|
298
318
|
if (bytes_read < 0) {
|
299
319
|
if (errno == EAGAIN) {
|
@@ -305,25 +325,24 @@ static VALUE NIO_ByteBuffer_read_from(VALUE self, VALUE io)
|
|
305
325
|
|
306
326
|
buffer->position += bytes_read;
|
307
327
|
|
308
|
-
return
|
328
|
+
return SIZET2NUM(bytes_read);
|
309
329
|
}
|
310
330
|
|
311
331
|
static VALUE NIO_ByteBuffer_write_to(VALUE self, VALUE io)
|
312
332
|
{
|
313
333
|
struct NIO_ByteBuffer *buffer;
|
314
|
-
rb_io_t *fptr;
|
315
334
|
ssize_t nbytes, bytes_written;
|
316
335
|
|
317
336
|
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
|
318
|
-
|
319
|
-
|
337
|
+
io = rb_convert_type(io, T_FILE, "IO", "to_io");
|
338
|
+
io_set_nonblock(io);
|
320
339
|
|
321
340
|
nbytes = buffer->limit - buffer->position;
|
322
341
|
if (nbytes == 0) {
|
323
342
|
rb_raise(cNIO_ByteBuffer_UnderflowError, "no data remaining in buffer");
|
324
343
|
}
|
325
344
|
|
326
|
-
bytes_written = write(
|
345
|
+
bytes_written = write(rb_io_descriptor(io), buffer->buffer + buffer->position, nbytes);
|
327
346
|
|
328
347
|
if (bytes_written < 0) {
|
329
348
|
if (errno == EAGAIN) {
|
@@ -335,7 +354,7 @@ static VALUE NIO_ByteBuffer_write_to(VALUE self, VALUE io)
|
|
335
354
|
|
336
355
|
buffer->position += bytes_written;
|
337
356
|
|
338
|
-
return
|
357
|
+
return SIZET2NUM(bytes_written);
|
339
358
|
}
|
340
359
|
|
341
360
|
static VALUE NIO_ByteBuffer_flip(VALUE self)
|
data/ext/nio4r/extconf.rb
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2011-2020, by Tony Arcieri.
|
5
|
+
# Copyright, 2014, by Hiroshi Shibata.
|
6
|
+
# Copyright, 2014, by Sergey Avseyev.
|
7
|
+
# Copyright, 2015, by Daniel Berger.
|
8
|
+
# Copyright, 2017, by Jun Aruga.
|
9
|
+
# Copyright, 2017, by Usaku Nakamura.
|
10
|
+
# Copyright, 2017, by Lars Kanis.
|
11
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
12
|
+
# Copyright, 2020, by Gregory Longtin.
|
13
|
+
# Copyright, 2020, by Boaz Segev.
|
14
|
+
# Copyright, 2020, by Joao Fernandes.
|
15
|
+
# Copyright, 2021, by Jeffrey Martin.
|
16
|
+
|
3
17
|
require "rubygems"
|
4
18
|
|
5
19
|
# Write a dummy Makefile on Windows because we use the pure Ruby implementation there
|
@@ -16,6 +30,7 @@ end
|
|
16
30
|
require "mkmf"
|
17
31
|
|
18
32
|
have_header("unistd.h")
|
33
|
+
have_func("rb_io_descriptor")
|
19
34
|
|
20
35
|
$defs << "-DEV_USE_LINUXAIO" if have_header("linux/aio_abi.h")
|
21
36
|
$defs << "-DEV_USE_IOURING" if have_header("linux/io_uring.h")
|
data/ext/nio4r/monitor.c
CHANGED
@@ -34,6 +34,18 @@ static VALUE NIO_Monitor_readiness(VALUE self);
|
|
34
34
|
static int NIO_Monitor_symbol2interest(VALUE interests);
|
35
35
|
static void NIO_Monitor_update_interests(VALUE self, int interests);
|
36
36
|
|
37
|
+
/* Compatibility for Ruby <= 3.1 */
|
38
|
+
#ifndef HAVE_RB_IO_DESCRIPTOR
|
39
|
+
static int
|
40
|
+
io_descriptor_fallback(VALUE io)
|
41
|
+
{
|
42
|
+
rb_io_t *fptr;
|
43
|
+
GetOpenFile(io, fptr);
|
44
|
+
return fptr->fd;
|
45
|
+
}
|
46
|
+
#define rb_io_descriptor io_descriptor_fallback
|
47
|
+
#endif
|
48
|
+
|
37
49
|
/* Monitor control how a channel is being waited for by a monitor */
|
38
50
|
void Init_NIO_Monitor()
|
39
51
|
{
|
@@ -81,7 +93,6 @@ static VALUE NIO_Monitor_initialize(VALUE self, VALUE io, VALUE interests, VALUE
|
|
81
93
|
struct NIO_Monitor *monitor;
|
82
94
|
struct NIO_Selector *selector;
|
83
95
|
ID interests_id;
|
84
|
-
rb_io_t *fptr;
|
85
96
|
|
86
97
|
interests_id = SYM2ID(interests);
|
87
98
|
|
@@ -97,8 +108,8 @@ static VALUE NIO_Monitor_initialize(VALUE self, VALUE io, VALUE interests, VALUE
|
|
97
108
|
rb_raise(rb_eArgError, "invalid event type %s (must be :r, :w, or :rw)", RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0)));
|
98
109
|
}
|
99
110
|
|
100
|
-
|
101
|
-
ev_io_init(&monitor->ev_io, NIO_Selector_monitor_callback,
|
111
|
+
int descriptor = rb_io_descriptor(rb_convert_type(io, T_FILE, "IO", "to_io"));
|
112
|
+
ev_io_init(&monitor->ev_io, NIO_Selector_monitor_callback, descriptor, monitor->interests);
|
102
113
|
|
103
114
|
rb_ivar_set(self, rb_intern("io"), io);
|
104
115
|
rb_ivar_set(self, rb_intern("interests"), interests);
|
@@ -182,7 +193,7 @@ static VALUE NIO_Monitor_add_interest(VALUE self, VALUE interest)
|
|
182
193
|
Data_Get_Struct(self, struct NIO_Monitor, monitor);
|
183
194
|
|
184
195
|
interest = monitor->interests | NIO_Monitor_symbol2interest(interest);
|
185
|
-
NIO_Monitor_update_interests(self, interest);
|
196
|
+
NIO_Monitor_update_interests(self, (int)interest);
|
186
197
|
|
187
198
|
return rb_ivar_get(self, rb_intern("interests"));
|
188
199
|
}
|
@@ -193,7 +204,7 @@ static VALUE NIO_Monitor_remove_interest(VALUE self, VALUE interest)
|
|
193
204
|
Data_Get_Struct(self, struct NIO_Monitor, monitor);
|
194
205
|
|
195
206
|
interest = monitor->interests & ~NIO_Monitor_symbol2interest(interest);
|
196
|
-
NIO_Monitor_update_interests(self, interest);
|
207
|
+
NIO_Monitor_update_interests(self, (int)interest);
|
197
208
|
|
198
209
|
return rb_ivar_get(self, rb_intern("interests"));
|
199
210
|
}
|
data/ext/nio4r/nio4r.h
CHANGED
@@ -40,12 +40,6 @@ struct NIO_ByteBuffer {
|
|
40
40
|
int position, limit, capacity, mark;
|
41
41
|
};
|
42
42
|
|
43
|
-
#ifdef GetReadFile
|
44
|
-
#define FPTR_TO_FD(fptr) (fileno(GetReadFile(fptr)))
|
45
|
-
#else
|
46
|
-
#define FPTR_TO_FD(fptr) fptr->fd
|
47
|
-
#endif /* GetReadFile */
|
48
|
-
|
49
43
|
/* Thunk between libev callbacks in NIO::Monitors and NIO::Selectors */
|
50
44
|
void NIO_Selector_monitor_callback(struct ev_loop *ev_loop, struct ev_io *io, int revents);
|
51
45
|
|
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/lib/nio4r_ext.jar
CHANGED
Binary file
|
data/license.md
CHANGED
@@ -1,43 +1,53 @@
|
|
1
1
|
# MIT License
|
2
2
|
|
3
|
-
Copyright, 2011-2020, by Tony Arcieri.
|
4
|
-
Copyright, 2012, by
|
5
|
-
Copyright,
|
6
|
-
Copyright,
|
7
|
-
Copyright, 2013, by
|
8
|
-
Copyright, 2013, by
|
9
|
-
Copyright, 2013, by
|
10
|
-
Copyright,
|
11
|
-
Copyright,
|
12
|
-
Copyright,
|
13
|
-
Copyright,
|
14
|
-
Copyright,
|
15
|
-
Copyright,
|
16
|
-
Copyright,
|
17
|
-
Copyright,
|
18
|
-
Copyright,
|
19
|
-
Copyright,
|
20
|
-
Copyright,
|
21
|
-
Copyright,
|
22
|
-
Copyright,
|
23
|
-
Copyright,
|
24
|
-
Copyright,
|
25
|
-
Copyright,
|
26
|
-
Copyright,
|
27
|
-
Copyright,
|
28
|
-
Copyright,
|
29
|
-
Copyright,
|
30
|
-
Copyright,
|
31
|
-
Copyright,
|
32
|
-
Copyright,
|
33
|
-
Copyright,
|
34
|
-
Copyright, 2020, by
|
35
|
-
Copyright,
|
36
|
-
Copyright,
|
37
|
-
Copyright,
|
38
|
-
Copyright,
|
39
|
-
Copyright,
|
40
|
-
Copyright,
|
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-2023, 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, by Pavel Rosický.
|
49
|
+
Copyright, 2023, by Tsimnuj Hawj.
|
50
|
+
Copyright, 2023, by Phillip Aldridge.
|
41
51
|
|
42
52
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
43
53
|
of this software and associated documentation files (the "Software"), to deal
|
data/nio4r.gemspec
CHANGED
@@ -25,7 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
"changelog_uri" => "https://github.com/socketry/nio4r/blob/master/CHANGES.md",
|
26
26
|
"documentation_uri" => "https://www.rubydoc.info/gems/nio4r/#{spec.version}",
|
27
27
|
"source_code_uri" => "https://github.com/socketry/nio4r/tree/v#{spec.version}",
|
28
|
-
"wiki_uri" => "https://github.com/socketry/nio4r/wiki"
|
28
|
+
"wiki_uri" => "https://github.com/socketry/nio4r/wiki",
|
29
|
+
"funding_uri" => "https://github.com/sponsors/ioquatix/",
|
29
30
|
}
|
30
31
|
|
31
32
|
spec.required_ruby_version = ">= 2.4"
|
data/readme.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# 
|
2
|
+
|
3
|
+
[](http://rubygems.org/gems/nio4r)
|
4
|
+
[](https://github.com/socketry/nio4r/actions?query=workflow:nio4r)
|
5
|
+
[](https://codeclimate.com/github/socketry/nio4r)
|
6
|
+
[](http://www.rubydoc.info/gems/nio4r/2.2.0)
|
7
|
+
|
8
|
+
**New I/O for Ruby (nio4r)**: cross-platform asynchronous I/O primitives for
|
9
|
+
scalable network clients and servers. Modeled after the Java NIO API, but
|
10
|
+
simplified for ease-of-use.
|
11
|
+
|
12
|
+
**nio4r** provides an abstract, cross-platform stateful I/O selector API for Ruby.
|
13
|
+
I/O selectors are the heart of "reactor"-based event loops, and monitor
|
14
|
+
multiple I/O objects for various types of readiness, e.g. ready for reading or
|
15
|
+
writing.
|
16
|
+
|
17
|
+
## Projects using nio4r
|
18
|
+
|
19
|
+
- [ActionCable](https://rubygems.org/gems/actioncable): Rails 5 WebSocket protocol, uses nio4r for a WebSocket server
|
20
|
+
- [Celluloid](https://github.com/celluloid/celluloid-io): Actor-based concurrency framework, uses nio4r for async I/O
|
21
|
+
- [Async](https://github.com/socketry/async): Asynchronous I/O framework for Ruby
|
22
|
+
- [Puma](https://github.com/puma/puma): Ruby/Rack web server built for concurrency
|
23
|
+
|
24
|
+
## Goals
|
25
|
+
|
26
|
+
- Expose high-level interfaces for stateful IO selectors
|
27
|
+
- Keep the API small to maximize both portability and performance across many
|
28
|
+
different OSes and Ruby VMs
|
29
|
+
- Provide inherently thread-safe facilities for working with IO objects
|
30
|
+
|
31
|
+
## Supported platforms
|
32
|
+
|
33
|
+
- Ruby 2.4
|
34
|
+
- Ruby 2.5
|
35
|
+
- Ruby 2.6
|
36
|
+
- Ruby 2.7
|
37
|
+
- Ruby 3.0
|
38
|
+
- [JRuby](https://github.com/jruby/jruby)
|
39
|
+
- [TruffleRuby](https://github.com/oracle/truffleruby)
|
40
|
+
|
41
|
+
## Supported backends
|
42
|
+
|
43
|
+
- **libev**: MRI C extension targeting multiple native IO selector APIs (e.g epoll, kqueue)
|
44
|
+
- **Java NIO**: JRuby extension which wraps the Java NIO subsystem
|
45
|
+
- **Pure Ruby**: `Kernel.select`-based backend that should work on any Ruby interpreter
|
46
|
+
|
47
|
+
## Documentation
|
48
|
+
|
49
|
+
[Please see the nio4r wiki](https://github.com/socketry/nio4r/wiki)
|
50
|
+
for more detailed documentation and usage notes:
|
51
|
+
|
52
|
+
- [Getting Started](https://github.com/socketry/nio4r/wiki/Getting-Started): Introduction to nio4r's components
|
53
|
+
- [Selectors](https://github.com/socketry/nio4r/wiki/Selectors): monitor multiple `IO` objects for readiness events
|
54
|
+
- [Monitors](https://github.com/socketry/nio4r/wiki/Monitors): control interests and inspect readiness for specific `IO` objects
|
55
|
+
- [Byte Buffers](https://github.com/socketry/nio4r/wiki/Byte-Buffers): fixed-size native buffers for high-performance I/O
|
56
|
+
|
57
|
+
See also:
|
58
|
+
|
59
|
+
- [YARD API documentation](http://www.rubydoc.info/gems/nio4r/frames)
|
60
|
+
|
61
|
+
## Non-goals
|
62
|
+
|
63
|
+
**nio4r** is not a full-featured event framework like [EventMachine](https://github.com/eventmachine/eventmachine) or [Cool.io](https://coolio.github.io/).
|
64
|
+
Instead, nio4r is the sort of thing you might write a library like that on
|
65
|
+
top of. nio4r provides a minimal API such that individual Ruby implementers
|
66
|
+
may choose to produce optimized versions for their platform, without having
|
67
|
+
to maintain a large codebase.
|
68
|
+
|
69
|
+
## Releases
|
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/spec/nio/bytebuffer_spec.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, 2019-2023, by Samuel Williams.
|
7
|
+
# Copyright, 2020, by Thomas Dziedzic.
|
8
|
+
|
3
9
|
require "spec_helper"
|
4
10
|
|
5
11
|
RSpec.describe NIO::ByteBuffer do
|
data/spec/nio/monitor_spec.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, 2012, by Logan Bowers.
|
6
|
+
# Copyright, 2015, by Tiago Cardoso.
|
7
|
+
# Copyright, 2015, by Upekshe Jayasekera.
|
8
|
+
# Copyright, 2018-2023, by Samuel Williams.
|
9
|
+
|
3
10
|
require "spec_helper"
|
4
11
|
require "socket"
|
5
12
|
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2017, by Tony Arcieri.
|
5
|
+
# Copyright, 2012, by Logan Bowers.
|
6
|
+
# Copyright, 2017, by Gregory Longtin.
|
7
|
+
# Copyright, 2023, by Samuel Williams.
|
8
|
+
|
3
9
|
require "spec_helper"
|
4
10
|
|
5
11
|
RSpec.describe "IO.pipe" do
|
@@ -1,5 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2017, by Tony Arcieri.
|
5
|
+
# Copyright, 2012, by Logan Bowers.
|
6
|
+
# Copyright, 2017-2020, by Gregory Longtin.
|
7
|
+
# Copyright, 2019, by Cédric Boutillier.
|
8
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
9
|
+
|
3
10
|
require "spec_helper"
|
4
11
|
require "openssl"
|
5
12
|
|
@@ -1,5 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2017, by Tony Arcieri.
|
5
|
+
# Copyright, 2012, by Bernd Ahlers.
|
6
|
+
# Copyright, 2012, by Logan Bowers.
|
7
|
+
# Copyright, 2013, by Tim Carey-Smith.
|
8
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
9
|
+
|
3
10
|
require "spec_helper"
|
4
11
|
|
5
12
|
RSpec.describe TCPSocket do
|
@@ -1,5 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2017, by Tony Arcieri.
|
5
|
+
# Copyright, 2017, by Gregory Longtin.
|
6
|
+
# Copyright, 2017, by Olle Jonsson.
|
7
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
8
|
+
# Copyright, 2020, by Thomas Dziedzic.
|
9
|
+
|
3
10
|
require "spec_helper"
|
4
11
|
|
5
12
|
RSpec.describe UDPSocket, if: !defined?(JRUBY_VERSION) do
|
data/spec/nio/selector_spec.rb
CHANGED
@@ -1,5 +1,17 @@
|
|
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 Ravil Bayramgalin.
|
7
|
+
# Copyright, 2013, by Tim Carey-Smith.
|
8
|
+
# Copyright, 2015, by Vladimir Kochnev.
|
9
|
+
# Copyright, 2016, by Tiago Cardoso.
|
10
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
11
|
+
# Copyright, 2019, by Jesús Burgos Maciá.
|
12
|
+
# Copyright, 2020, by Thomas Dziedzic.
|
13
|
+
# Copyright, 2021, by Joao Fernandes.
|
14
|
+
|
3
15
|
require "spec_helper"
|
4
16
|
require "timeout"
|
5
17
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2011-2017, by Tony Arcieri.
|
5
|
+
# Copyright, 2017, by Gregory Longtin.
|
6
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
7
|
+
# Copyright, 2021, by Joao Fernandes.
|
8
|
+
|
3
9
|
require "nio"
|
4
10
|
require "support/selectable_examples"
|
5
11
|
|
@@ -1,5 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2012-2017, by Tony Arcieri.
|
5
|
+
# Copyright, 2012, by Logan Bowers.
|
6
|
+
# Copyright, 2013, by Tim Carey-Smith.
|
7
|
+
# Copyright, 2017-2019, by Gregory Longtin.
|
8
|
+
# Copyright, 2017, by Tiago Cardoso.
|
9
|
+
# Copyright, 2019-2023, by Samuel Williams.
|
10
|
+
|
3
11
|
RSpec.shared_context NIO::Selector do
|
4
12
|
let(:selector) {@selector = NIO::Selector.new}
|
5
13
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nio4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,12 +48,12 @@ extra_rdoc_files: []
|
|
48
48
|
files:
|
49
49
|
- ".github/workflows/workflow.yml"
|
50
50
|
- ".gitignore"
|
51
|
+
- ".mailmap"
|
51
52
|
- ".rspec"
|
52
53
|
- ".rubocop.yml"
|
53
|
-
- CHANGES.md
|
54
54
|
- Gemfile
|
55
|
-
- README.md
|
56
55
|
- Rakefile
|
56
|
+
- changes.md
|
57
57
|
- examples/echo_server.rb
|
58
58
|
- ext/libev/Changes
|
59
59
|
- ext/libev/LICENSE
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/nio/monitor.rb
|
88
88
|
- lib/nio/selector.rb
|
89
89
|
- lib/nio/version.rb
|
90
|
+
- lib/nio4r.rb
|
90
91
|
- lib/nio4r_ext.jar
|
91
92
|
- license.md
|
92
93
|
- logo.png
|
@@ -94,6 +95,7 @@ files:
|
|
94
95
|
- rakelib/extension.rake
|
95
96
|
- rakelib/rspec.rake
|
96
97
|
- rakelib/rubocop.rake
|
98
|
+
- readme.md
|
97
99
|
- spec/nio/acceptables_spec.rb
|
98
100
|
- spec/nio/bytebuffer_spec.rb
|
99
101
|
- spec/nio/monitor_spec.rb
|
@@ -110,9 +112,10 @@ licenses:
|
|
110
112
|
metadata:
|
111
113
|
bug_tracker_uri: https://github.com/socketry/nio4r/issues
|
112
114
|
changelog_uri: https://github.com/socketry/nio4r/blob/master/CHANGES.md
|
113
|
-
documentation_uri: https://www.rubydoc.info/gems/nio4r/2.
|
114
|
-
source_code_uri: https://github.com/socketry/nio4r/tree/v2.
|
115
|
+
documentation_uri: https://www.rubydoc.info/gems/nio4r/2.6.1
|
116
|
+
source_code_uri: https://github.com/socketry/nio4r/tree/v2.6.1
|
115
117
|
wiki_uri: https://github.com/socketry/nio4r/wiki
|
118
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
116
119
|
post_install_message:
|
117
120
|
rdoc_options: []
|
118
121
|
require_paths:
|
data/README.md
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
# 
|
2
|
-
|
3
|
-
[](http://rubygems.org/gems/nio4r)
|
4
|
-
[](https://github.com/socketry/nio4r/actions?query=workflow:nio4r)
|
5
|
-
[](https://codeclimate.com/github/socketry/nio4r)
|
6
|
-
[](http://www.rubydoc.info/gems/nio4r/2.2.0)
|
7
|
-
|
8
|
-
**New I/O for Ruby (nio4r)**: cross-platform asynchronous I/O primitives for
|
9
|
-
scalable network clients and servers. Modeled after the Java NIO API, but
|
10
|
-
simplified for ease-of-use.
|
11
|
-
|
12
|
-
**nio4r** provides an abstract, cross-platform stateful I/O selector API for Ruby.
|
13
|
-
I/O selectors are the heart of "reactor"-based event loops, and monitor
|
14
|
-
multiple I/O objects for various types of readiness, e.g. ready for reading or
|
15
|
-
writing.
|
16
|
-
|
17
|
-
## Projects using nio4r
|
18
|
-
|
19
|
-
* [ActionCable]: Rails 5 WebSocket protocol, uses nio4r for a WebSocket server
|
20
|
-
* [Celluloid]: Actor-based concurrency framework, uses nio4r for async I/O
|
21
|
-
* [Async]: Asynchronous I/O framework for Ruby
|
22
|
-
* [Puma]: Ruby/Rack web server built for concurrency
|
23
|
-
|
24
|
-
[ActionCable]: https://rubygems.org/gems/actioncable
|
25
|
-
[Celluloid]: https://github.com/celluloid/celluloid-io
|
26
|
-
[Async]: https://github.com/socketry/async
|
27
|
-
[Puma]: https://github.com/puma/puma
|
28
|
-
|
29
|
-
## Goals
|
30
|
-
|
31
|
-
* Expose high-level interfaces for stateful IO selectors
|
32
|
-
* Keep the API small to maximize both portability and performance across many
|
33
|
-
different OSes and Ruby VMs
|
34
|
-
* Provide inherently thread-safe facilities for working with IO objects
|
35
|
-
|
36
|
-
## Supported platforms
|
37
|
-
|
38
|
-
* Ruby 2.4
|
39
|
-
* Ruby 2.5
|
40
|
-
* Ruby 2.6
|
41
|
-
* Ruby 2.7
|
42
|
-
* Ruby 3.0
|
43
|
-
* [JRuby](https://github.com/jruby/jruby)
|
44
|
-
* [TruffleRuby](https://github.com/oracle/truffleruby)
|
45
|
-
|
46
|
-
## Supported backends
|
47
|
-
|
48
|
-
* **libev**: MRI C extension targeting multiple native IO selector APIs (e.g epoll, kqueue)
|
49
|
-
* **Java NIO**: JRuby extension which wraps the Java NIO subsystem
|
50
|
-
* **Pure Ruby**: `Kernel.select`-based backend that should work on any Ruby interpreter
|
51
|
-
|
52
|
-
## Documentation
|
53
|
-
|
54
|
-
[Please see the nio4r wiki](https://github.com/socketry/nio4r/wiki)
|
55
|
-
for more detailed documentation and usage notes:
|
56
|
-
|
57
|
-
* [Getting Started]: Introduction to nio4r's components
|
58
|
-
* [Selectors]: monitor multiple `IO` objects for readiness events
|
59
|
-
* [Monitors]: control interests and inspect readiness for specific `IO` objects
|
60
|
-
* [Byte Buffers]: fixed-size native buffers for high-performance I/O
|
61
|
-
|
62
|
-
[Getting Started]: https://github.com/socketry/nio4r/wiki/Getting-Started
|
63
|
-
[Selectors]: https://github.com/socketry/nio4r/wiki/Selectors
|
64
|
-
[Monitors]: https://github.com/socketry/nio4r/wiki/Monitors
|
65
|
-
[Byte Buffers]: https://github.com/socketry/nio4r/wiki/Byte-Buffers
|
66
|
-
|
67
|
-
See also:
|
68
|
-
|
69
|
-
* [YARD API documentation](http://www.rubydoc.info/gems/nio4r/frames)
|
70
|
-
|
71
|
-
## Non-goals
|
72
|
-
|
73
|
-
**nio4r** is not a full-featured event framework like [EventMachine] or [Cool.io].
|
74
|
-
Instead, nio4r is the sort of thing you might write a library like that on
|
75
|
-
top of. nio4r provides a minimal API such that individual Ruby implementers
|
76
|
-
may choose to produce optimized versions for their platform, without having
|
77
|
-
to maintain a large codebase.
|
78
|
-
|
79
|
-
[EventMachine]: https://github.com/eventmachine/eventmachine
|
80
|
-
[Cool.io]: https://coolio.github.io/
|
81
|
-
|
82
|
-
## Releases
|
83
|
-
|
84
|
-
### CRuby
|
85
|
-
|
86
|
-
```
|
87
|
-
rake clean
|
88
|
-
rake release
|
89
|
-
```
|
90
|
-
|
91
|
-
### JRuby
|
92
|
-
|
93
|
-
You might need to delete `Gemfile.lock` before trying to `bundle install`.
|
94
|
-
|
95
|
-
```
|
96
|
-
rake clean
|
97
|
-
rake compile
|
98
|
-
rake release
|
99
|
-
```
|