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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cc6abcf010ce881e4623a5736241660d1ebf6a84883767d761616ddcb23bf4e
4
- data.tar.gz: 4a438756e87e8feaefaafb40014f36c2b240fbbd837d4581c657eb310cb9b95a
3
+ metadata.gz: 634a83d174720978fa28231fa599a3f9ac4b27bc727b4fd934a3999ccd3b0df0
4
+ data.tar.gz: 0f34bf53b9103e3dc55f545c479c8850ca0b22425caba6029d3c7dbb93b3b322
5
5
  SHA512:
6
- metadata.gz: b910e009ff697f179290d916e5914621d25a5478e0f09ac806563a0c3808b30fc28ca652042608e60625830468f37088943559c590112dfadb0d3a48d3b54688
7
- data.tar.gz: c7501e4ef87e5c9744d666e43494b60b2b3c490d9e9cb55b75a87f7de199e1421b49ba0ce5e176cbaf230d6f3b8f838a5745cff81bac6f826328e7665de7a9e9
6
+ metadata.gz: bcce50b95a8f978df63deb0e41bda0e9ea4911ea2ba7a1074628fbce6d6b59d314008ec0ca2cc165a067f020f079bb6940df822732a31f92fab96187cc3bffdd
7
+ data.tar.gz: f77dd827a584493fe156cc0f61b07bfa1b3081a514cf591bb156228c6b23b7d54bb1f15c2bb73e9b3a65bd4be6eb13d508a933fdf1a78e2ff314e59b8a79e370
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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
- selector.io_wait(Fiber.current, input, IO::READABLE)
38
- pp read: input.read
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
- # The reader will be blocked until the IO has data available:
55
+ puts "[main] Transferring to reader fiber"
42
56
  reader.transfer
43
57
 
44
- # Write some data to the pipe and close the writing end:
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
- # {:read=>"Hello World"}
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
- # We might want to consider using this in the future:
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->tail;
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.