io-event 1.4.1 → 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: f4bd8777ff57783824a685d4e0908529f5d01e9b92a2a6658e23eedb375b3057
4
- data.tar.gz: 10357b88e548e2ac27c41c3c2a2fec2b50597e2a0f7a4bf4e848b3791ae13cc5
3
+ metadata.gz: a0dd172aa1e65b9163bea2a39c1294f147c21eddcd22b3bd9439431329d8dd66
4
+ data.tar.gz: bdc9e0a4fc251b721f3cbdd06350f82f17b07a2e8d114ce68ec998c88e5993ef
5
5
  SHA512:
6
- metadata.gz: 9ff2f5f264f709a85b25914d85fdff972e52fd49473e4c989324ee97de37956510c59546f3e5615a0c88457c88f9b3efb49d96ecb61a505220f0e96ae1845f23
7
- data.tar.gz: edc21d2c9e319d0688a3806c3d34029e9d98bf77aeee125542d3daeac1ac2b21e4023c7e30fbc1d5d30b8d5e70ea6ee8e7c5630e37157759eb8e2f9086ff6d8a
6
+ metadata.gz: 3beab3c2611dce16f10ec3045adad764b5c4ae67ac406ef9440a892d3d2eccac1cb9981d6bf5a027b19fdc665387a7b7b22b0144f595bf00beae44c9a3c83188
7
+ data.tar.gz: 33a62cc1ca97e50a6637baff60fd7a46d4003b81f66266496e3535fa4c732f07179ddbd920f7b97e25f43cc21e8394641db76d0b5ea8c16ee77c0d2619d085b5
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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.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.1
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: 2024-01-10 00:00:00.000000000 Z
45
+ date: 2024-01-15 00:00:00.000000000 Z
46
46
  dependencies: []
47
47
  description:
48
48
  email:
metadata.gz.sig CHANGED
Binary file