io-event 1.4.1 → 1.4.3

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: f4bd8777ff57783824a685d4e0908529f5d01e9b92a2a6658e23eedb375b3057
4
- data.tar.gz: 10357b88e548e2ac27c41c3c2a2fec2b50597e2a0f7a4bf4e848b3791ae13cc5
3
+ metadata.gz: 48833d95b36913a471c49a15933705c021582488d4f0a83ab26b2cc08a39b092
4
+ data.tar.gz: c2ad33420135a7a72315e71362b4663503bf6bc8c6561cf4416bfc8e42f5398c
5
5
  SHA512:
6
- metadata.gz: 9ff2f5f264f709a85b25914d85fdff972e52fd49473e4c989324ee97de37956510c59546f3e5615a0c88457c88f9b3efb49d96ecb61a505220f0e96ae1845f23
7
- data.tar.gz: edc21d2c9e319d0688a3806c3d34029e9d98bf77aeee125542d3daeac1ac2b21e4023c7e30fbc1d5d30b8d5e70ea6ee8e7c5630e37157759eb8e2f9086ff6d8a
6
+ metadata.gz: ebc42847281fc77b058ab6b66c582ea7b58889eb28739c0d25f252b76c037d6341d53b06695595eae413fe67b1f9d10f564c110f01b379ccd10cc628a92e309c
7
+ data.tar.gz: a6d0dc1b314cc5c05e5284bfd5d981436ae932bc399355c4cd9d1e9f2ea033c794d4f526c23de64cfbb9f7df5f39058e2511b79fcaebaeec0365c1a5aca919f6
checksums.yaml.gz.sig CHANGED
Binary file
@@ -34,6 +34,7 @@
34
34
  #endif
35
35
 
36
36
  #include <time.h>
37
+ #include <sys/wait.h>
37
38
 
38
39
  enum IO_Event {
39
40
  IO_EVENT_READABLE = 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.1"
8
+ VERSION = "1.4.3"
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.1
4
+ version: 1.4.3
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: 2024-01-10 00:00:00.000000000 Z
45
+ date: 2024-02-05 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.4.10
100
+ rubygems_version: 3.5.5
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: An event loop.
metadata.gz.sig CHANGED
Binary file