io-event 1.16.2 → 1.21.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
- checksums.yaml.gz.sig +0 -0
- data/context/getting-started.md +31 -5
- data/ext/extconf.rb +4 -4
- data/ext/io/event/list.h +1 -1
- data/ext/io/event/selector/epoll.c +196 -97
- data/ext/io/event/selector/kqueue.c +195 -101
- data/ext/io/event/selector/selector.c +77 -1
- data/ext/io/event/selector/selector.h +24 -2
- data/ext/io/event/selector/uring.c +508 -88
- data/ext/io/event/worker_pool.c +45 -34
- data/lib/io/event/debug/selector.rb +13 -6
- data/lib/io/event/interrupt.rb +12 -7
- data/lib/io/event/selector/select.rb +108 -58
- data/lib/io/event/selector.rb +24 -9
- data/lib/io/event/timers.rb +1 -1
- data/lib/io/event/version.rb +1 -1
- data/license.md +1 -0
- data/readme.md +22 -26
- data/releases.md +50 -0
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 634a83d174720978fa28231fa599a3f9ac4b27bc727b4fd934a3999ccd3b0df0
|
|
4
|
+
data.tar.gz: 0f34bf53b9103e3dc55f545c479c8850ca0b22425caba6029d3c7dbb93b3b322
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bcce50b95a8f978df63deb0e41bda0e9ea4911ea2ba7a1074628fbce6d6b59d314008ec0ca2cc165a067f020f079bb6940df822732a31f92fab96187cc3bffdd
|
|
7
|
+
data.tar.gz: f77dd827a584493fe156cc0f61b07bfa1b3081a514cf591bb156228c6b23b7d54bb1f15c2bb73e9b3a65bd4be6eb13d508a933fdf1a78e2ff314e59b8a79e370
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/context/getting-started.md
CHANGED
|
@@ -25,29 +25,55 @@ This example shows how to perform a blocking operation
|
|
|
25
25
|
require "fiber"
|
|
26
26
|
require "io/event"
|
|
27
27
|
|
|
28
|
+
# Create an I/O event selector controlled by the main Fiber.
|
|
28
29
|
selector = IO::Event::Selector.new(Fiber.current)
|
|
30
|
+
|
|
31
|
+
# input: read end, output: write end.
|
|
29
32
|
input, output = IO.pipe
|
|
30
33
|
|
|
31
34
|
writer = Fiber.new do
|
|
35
|
+
puts "[writer] Writing data"
|
|
36
|
+
|
|
32
37
|
output.write("Hello World")
|
|
33
38
|
output.close
|
|
34
39
|
end
|
|
35
40
|
|
|
36
41
|
reader = Fiber.new do
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
puts "[reader] No data available, waiting for input"
|
|
43
|
+
|
|
44
|
+
# Suspend this Fiber until the input becomes readable.
|
|
45
|
+
selector.io_wait(
|
|
46
|
+
Fiber.current,
|
|
47
|
+
input,
|
|
48
|
+
IO::READABLE
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Execution resumes here once the selector detects the event.
|
|
52
|
+
puts "[reader] Received: #{input.read.inspect}"
|
|
39
53
|
end
|
|
40
54
|
|
|
41
|
-
|
|
55
|
+
puts "[main] Transferring to reader fiber"
|
|
42
56
|
reader.transfer
|
|
43
57
|
|
|
44
|
-
|
|
58
|
+
puts "[main] Reader is waiting, but main can keep running"
|
|
59
|
+
|
|
60
|
+
puts "[main] Transferring to writer fiber"
|
|
45
61
|
writer.transfer
|
|
46
62
|
|
|
63
|
+
puts "[main] Checking for I/O events"
|
|
47
64
|
selector.select(1)
|
|
48
65
|
|
|
66
|
+
puts "[main] Done"
|
|
67
|
+
|
|
49
68
|
# Results in:
|
|
50
|
-
#
|
|
69
|
+
# [main] Transferring to reader fiber
|
|
70
|
+
# [reader] No data available, waiting for input
|
|
71
|
+
# [main] Reader is waiting, but main can keep running
|
|
72
|
+
# [main] Transferring to writer fiber
|
|
73
|
+
# [writer] Writing data
|
|
74
|
+
# [main] Checking for I/O events
|
|
75
|
+
# [reader] Received: "Hello World"
|
|
76
|
+
# [main] Done
|
|
51
77
|
```
|
|
52
78
|
|
|
53
79
|
## Debugging
|
data/ext/extconf.rb
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
# Copyright, 2023, by Math Ieu.
|
|
7
7
|
# Copyright, 2025, by Stanislav (Stas) Katkov.
|
|
8
8
|
# Copyright, 2026, by Stan Hu.
|
|
9
|
+
# Copyright, 2026, by Sharon Rosner.
|
|
9
10
|
|
|
10
11
|
return if RUBY_DESCRIPTION =~ /jruby/
|
|
11
12
|
|
|
@@ -32,9 +33,7 @@ have_func("rb_ext_ractor_safe")
|
|
|
32
33
|
have_func("&rb_fiber_transfer")
|
|
33
34
|
|
|
34
35
|
if have_library("uring") and have_header("liburing.h")
|
|
35
|
-
|
|
36
|
-
# have_func("io_uring_submit_and_wait_timeout", "liburing.h")
|
|
37
|
-
|
|
36
|
+
have_func("io_uring_prep_waitid", "liburing.h")
|
|
38
37
|
$srcs << "io/event/selector/uring.c"
|
|
39
38
|
end
|
|
40
39
|
|
|
@@ -52,10 +51,11 @@ have_header("sys/eventfd.h")
|
|
|
52
51
|
$srcs << "io/event/interrupt.c"
|
|
53
52
|
|
|
54
53
|
have_func("rb_io_descriptor")
|
|
54
|
+
have_func("rb_process_status_for")
|
|
55
55
|
have_func("&rb_process_status_wait")
|
|
56
56
|
have_func("rb_fiber_current")
|
|
57
57
|
have_func("&rb_fiber_raise")
|
|
58
|
-
have_func("epoll_pwait2") if enable_config("epoll_pwait2", true)
|
|
58
|
+
have_func("epoll_pwait2(0, 0, 0, 0, 0)", "sys/epoll.h") if enable_config("epoll_pwait2", true)
|
|
59
59
|
|
|
60
60
|
have_header("ruby/io/buffer.h")
|
|
61
61
|
|
data/ext/io/event/list.h
CHANGED
|
@@ -90,7 +90,7 @@ inline static size_t IO_Event_List_memory_size(const struct IO_Event_List *list)
|
|
|
90
90
|
// Return true if the list is empty.
|
|
91
91
|
inline static int IO_Event_List_empty(const struct IO_Event_List *list)
|
|
92
92
|
{
|
|
93
|
-
return list->head == list
|
|
93
|
+
return list->head == list;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// Enumerate all items in the list, assuming the list will not be modified during iteration.
|