io-event 1.4.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f53f20e456a5b4a5ef56e4293e9f8f080e30c16b6d3cd7022d7d8da22ebfe84
4
- data.tar.gz: cf6186d1eef0725483af5a47141dbf50bd6bcc96513bfd528c35dc693f4d7db2
3
+ metadata.gz: a0dd172aa1e65b9163bea2a39c1294f147c21eddcd22b3bd9439431329d8dd66
4
+ data.tar.gz: bdc9e0a4fc251b721f3cbdd06350f82f17b07a2e8d114ce68ec998c88e5993ef
5
5
  SHA512:
6
- metadata.gz: ff231970a60cedcec409eb1294de3c6a29eff82440bab558cc3618fc537b5461fb4514fbdc401d9a21630193a8ab293529579c191dc5d446c5eb45eccc3c4d4b
7
- data.tar.gz: 73a8a5cc5eb62fdc231b2d45c6591e367758ebb0e48a6a179a91877a08d6f0b9cd86ecf8c179ddab5f1cb81c0b05c9c8c345e0983de3e866ad420e189f7bbc4f
6
+ metadata.gz: 3beab3c2611dce16f10ec3045adad764b5c4ae67ac406ef9440a892d3d2eccac1cb9981d6bf5a027b19fdc665387a7b7b22b0144f595bf00beae44c9a3c83188
7
+ data.tar.gz: 33a62cc1ca97e50a6637baff60fd7a46d4003b81f66266496e3535fa4c732f07179ddbd920f7b97e25f43cc21e8394641db76d0b5ea8c16ee77c0d2619d085b5
checksums.yaml.gz.sig CHANGED
Binary file
data/ext/io/event/event.h CHANGED
@@ -22,8 +22,6 @@
22
22
 
23
23
  #include <ruby.h>
24
24
 
25
- #include "extconf.h"
26
-
27
25
  void Init_IO_Event(void);
28
26
 
29
27
  #ifdef HAVE_LIBURING_H
@@ -20,7 +20,7 @@
20
20
 
21
21
  #pragma once
22
22
 
23
- #include "extconf.h"
23
+ #include <ruby.h>
24
24
 
25
25
  #ifdef HAVE_SYS_EVENTFD_H
26
26
  struct IO_Event_Interrupt {
@@ -3,6 +3,7 @@
3
3
 
4
4
  // Provides a simple implementation of unique pointers to elements of the given size.
5
5
 
6
+ #include <ruby.h>
6
7
  #include <stdlib.h>
7
8
  #include <errno.h>
8
9
  #include <assert.h>
@@ -18,7 +18,7 @@
18
18
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  // THE SOFTWARE.
20
20
 
21
- #include "kqueue.h"
21
+ #include "epoll.h"
22
22
  #include "selector.h"
23
23
  #include "list.h"
24
24
  #include "array.h"
@@ -1,6 +1,7 @@
1
1
  // Released under the MIT License.
2
2
  // Copyright, 2023, by Samuel Williams.
3
3
 
4
+ #include <ruby.h>
4
5
  #include <stdio.h>
5
6
  #include <assert.h>
6
7
 
@@ -18,6 +18,8 @@
18
18
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  // THE SOFTWARE.
20
20
 
21
+ #include <ruby.h>
22
+
21
23
  #include <sys/types.h>
22
24
  #include <sys/syscall.h>
23
25
  #include <unistd.h>
@@ -602,7 +602,7 @@ static inline off_t io_seekable(int descriptor) {
602
602
  return -1;
603
603
  }
604
604
  #else
605
- #warning Upgrade your kernel to 5.16! io_uring bugs prevent efficient io_read/io_write hooks.
605
+ #warning Upgrade your kernel to 5.16+! io_uring bugs prevent efficient io_read/io_write hooks.
606
606
  static inline off_t io_seekable(int descriptor)
607
607
  {
608
608
  if (lseek(descriptor, 0, SEEK_CUR) == -1) {
@@ -9,7 +9,17 @@ module IO::Event
9
9
  module Debug
10
10
  # Enforces the selector interface and delegates operations to a wrapped selector instance.
11
11
  class Selector
12
- def initialize(selector)
12
+ def self.wrap(selector, env = ENV)
13
+ log = nil
14
+
15
+ if log_path = env['IO_EVENT_DEBUG_SELECTOR_LOG']
16
+ log = File.open(log_path, 'w')
17
+ end
18
+
19
+ return self.new(selector, log: log)
20
+ end
21
+
22
+ def initialize(selector, log: nil)
13
23
  @selector = selector
14
24
 
15
25
  @readable = {}
@@ -19,6 +29,20 @@ module IO::Event
19
29
  unless Fiber.current == selector.loop
20
30
  Kernel::raise "Selector must be initialized on event loop fiber!"
21
31
  end
32
+
33
+ @log = log
34
+ end
35
+
36
+ def now
37
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
38
+ end
39
+
40
+ def log(message)
41
+ return unless @log
42
+
43
+ Fiber.blocking do
44
+ @log.puts("T+%10.1f; %s" % [now, message])
45
+ end
22
46
  end
23
47
 
24
48
  def wakeup
@@ -26,6 +50,8 @@ module IO::Event
26
50
  end
27
51
 
28
52
  def close
53
+ log("Closing selector")
54
+
29
55
  if @selector.nil?
30
56
  Kernel::raise "Selector already closed!"
31
57
  end
@@ -36,22 +62,27 @@ module IO::Event
36
62
 
37
63
  # Transfer from the calling fiber to the event loop.
38
64
  def transfer
65
+ log("Transfering to event loop")
39
66
  @selector.transfer
40
67
  end
41
68
 
42
69
  def resume(*arguments)
70
+ log("Resuming fiber with #{arguments.inspect}")
43
71
  @selector.resume(*arguments)
44
72
  end
45
73
 
46
74
  def yield
75
+ log("Yielding to event loop")
47
76
  @selector.yield
48
77
  end
49
78
 
50
79
  def push(fiber)
80
+ log("Pushing fiber #{fiber.inspect} to ready list")
51
81
  @selector.push(fiber)
52
82
  end
53
83
 
54
84
  def raise(fiber, *arguments)
85
+ log("Raising exception on fiber #{fiber.inspect} with #{arguments.inspect}")
55
86
  @selector.raise(fiber, *arguments)
56
87
  end
57
88
 
@@ -60,19 +91,23 @@ module IO::Event
60
91
  end
61
92
 
62
93
  def process_wait(*arguments)
94
+ log("Waiting for process with #{arguments.inspect}")
63
95
  @selector.process_wait(*arguments)
64
96
  end
65
97
 
66
98
  def io_wait(fiber, io, events)
99
+ log("Waiting for IO #{io.inspect} for events #{events.inspect}")
67
100
  @selector.io_wait(fiber, io, events)
68
101
  end
69
102
 
70
- def io_read(...)
71
- @selector.io_read(...)
103
+ def io_read(fiber, io, buffer, length, offset = 0)
104
+ log("Reading from IO #{io.inspect} with buffer #{buffer}; length #{length} offset #{offset}")
105
+ @selector.io_read(fiber, io, buffer, length, offset)
72
106
  end
73
107
 
74
- def io_write(...)
75
- @selector.io_write(...)
108
+ def io_write(fiber, io, buffer, length, offset = 0)
109
+ log("Writing to IO #{io.inspect} with buffer #{buffer}; length #{length} offset #{offset}")
110
+ @selector.io_write(fiber, io, buffer, length, offset)
76
111
  end
77
112
 
78
113
  def respond_to?(name, include_private = false)
@@ -80,6 +115,7 @@ module IO::Event
80
115
  end
81
116
 
82
117
  def select(duration = nil)
118
+ log("Selecting for #{duration.inspect}")
83
119
  unless Fiber.current == @selector.loop
84
120
  Kernel::raise "Selector must be run on event loop fiber!"
85
121
  end
@@ -29,7 +29,7 @@ module IO::Event
29
29
  selector = default(env).new(loop)
30
30
 
31
31
  if debug = env['IO_EVENT_DEBUG_SELECTOR']
32
- selector = Debug::Selector.new(selector)
32
+ selector = Debug::Selector.wrap(selector, env)
33
33
  end
34
34
 
35
35
  return selector
@@ -5,6 +5,6 @@
5
5
 
6
6
  class IO
7
7
  module Event
8
- VERSION = "1.4.0"
8
+ VERSION = "1.4.2"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -42,7 +42,7 @@ cert_chain:
42
42
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
43
43
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
44
44
  -----END CERTIFICATE-----
45
- date: 2023-12-28 00:00:00.000000000 Z
45
+ date: 2024-01-15 00:00:00.000000000 Z
46
46
  dependencies: []
47
47
  description:
48
48
  email:
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.5.3
100
+ rubygems_version: 3.4.10
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: An event loop.
metadata.gz.sig CHANGED
Binary file