uringmachine 0.21.0 → 0.22.0
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
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +14 -0
- data/TODO.md +144 -0
- data/benchmark/README.md +173 -0
- data/benchmark/bm_io_pipe.rb +70 -0
- data/benchmark/bm_io_socketpair.rb +71 -0
- data/benchmark/bm_mutex_cpu.rb +57 -0
- data/benchmark/bm_mutex_io.rb +64 -0
- data/benchmark/bm_pg_client.rb +109 -0
- data/benchmark/bm_queue.rb +76 -0
- data/benchmark/chart.png +0 -0
- data/benchmark/common.rb +135 -0
- data/benchmark/dns_client.rb +47 -0
- data/{examples/bm_http_parse.rb → benchmark/http_parse.rb} +1 -1
- data/benchmark/run_bm.rb +8 -0
- data/benchmark/sqlite.rb +108 -0
- data/{examples/bm_write.rb → benchmark/write.rb} +4 -4
- data/ext/um/um.c +189 -100
- data/ext/um/um.h +36 -10
- data/ext/um/um_async_op.c +1 -1
- data/ext/um/um_class.c +87 -13
- data/ext/um/um_op.c +6 -0
- data/ext/um/um_sync.c +2 -2
- data/ext/um/um_utils.c +16 -0
- data/grant-2025/journal.md +118 -1
- data/grant-2025/tasks.md +48 -22
- data/lib/uringmachine/actor.rb +8 -0
- data/lib/uringmachine/dns_resolver.rb +1 -2
- data/lib/uringmachine/fiber_scheduler.rb +127 -81
- data/lib/uringmachine/version.rb +1 -1
- data/lib/uringmachine.rb +32 -3
- data/test/helper.rb +7 -18
- data/test/test_actor.rb +12 -3
- data/test/test_async_op.rb +10 -10
- data/test/test_fiber.rb +84 -1
- data/test/test_fiber_scheduler.rb +950 -47
- data/test/test_um.rb +297 -120
- data/uringmachine.gemspec +2 -1
- metadata +38 -16
- data/examples/bm_fileno.rb +0 -33
- data/examples/bm_queue.rb +0 -111
- data/examples/bm_side_running.rb +0 -83
- data/examples/bm_sqlite.rb +0 -89
- data/examples/dns_client.rb +0 -12
- /data/{examples/bm_mutex.rb → benchmark/mutex.rb} +0 -0
- /data/{examples/bm_mutex_single.rb → benchmark/mutex_single.rb} +0 -0
- /data/{examples/bm_send.rb → benchmark/send.rb} +0 -0
- /data/{examples/bm_snooze.rb → benchmark/snooze.rb} +0 -0
data/test/test_fiber.rb
CHANGED
|
@@ -141,9 +141,92 @@ class FiberJoinTest < UMBaseTest
|
|
|
141
141
|
end
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
+
class WaitFibersTest < UMBaseTest
|
|
145
|
+
def test_await_fibers
|
|
146
|
+
q = UM::Queue.new
|
|
147
|
+
x = nil
|
|
148
|
+
|
|
149
|
+
f = machine.spin do
|
|
150
|
+
x = 1
|
|
151
|
+
machine.push q, machine.shift(q) + 1
|
|
152
|
+
42
|
|
153
|
+
ensure
|
|
154
|
+
x = 0
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
assert_nil x
|
|
158
|
+
machine.snooze
|
|
159
|
+
assert_equal 1, x
|
|
160
|
+
|
|
161
|
+
machine.spin do
|
|
162
|
+
x = 2
|
|
163
|
+
machine.push q, 2
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
res = machine.await_fibers([f])
|
|
167
|
+
assert_equal 0, x
|
|
168
|
+
assert_equal 3, machine.shift(q)
|
|
169
|
+
assert_equal 1, res
|
|
170
|
+
|
|
171
|
+
done = nil
|
|
172
|
+
f = machine.spin { machine.snooze; done = true }
|
|
173
|
+
res = machine.await_fibers(f)
|
|
174
|
+
assert done
|
|
175
|
+
assert_equal 1, res
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def test_await_fibers_multiple
|
|
179
|
+
f1 = machine.spin do
|
|
180
|
+
:foo
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
f2 = machine.spin do
|
|
184
|
+
machine.sleep(0.001)
|
|
185
|
+
:bar
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
f3 = machine.spin do
|
|
189
|
+
:baz
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
res = machine.await_fibers([f1, f2, f3])
|
|
193
|
+
assert_equal 3, res
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def test_await_fibers_cross_thread
|
|
197
|
+
q = UM::Queue.new
|
|
198
|
+
|
|
199
|
+
t2 = Thread.new do
|
|
200
|
+
m2 = UM.new
|
|
201
|
+
f = m2.spin do
|
|
202
|
+
m2.push(q, f)
|
|
203
|
+
m2.snooze
|
|
204
|
+
:foo
|
|
205
|
+
end
|
|
206
|
+
m2.await_fibers(f)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
f = machine.shift(q)
|
|
210
|
+
assert_kind_of Fiber, f
|
|
211
|
+
res = machine.await_fibers(f)
|
|
212
|
+
assert_equal 1, res
|
|
213
|
+
ensure
|
|
214
|
+
t2.join
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def test_await_fibers_with_exception
|
|
218
|
+
f = machine.spin do
|
|
219
|
+
raise "Foobar"
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
res = machine.await_fibers(f)
|
|
223
|
+
assert_equal 1, res
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
144
227
|
class ScopeTest < UMBaseTest
|
|
145
228
|
def test_scope
|
|
146
|
-
skip
|
|
229
|
+
skip("UM#scope not yet implemented")
|
|
147
230
|
|
|
148
231
|
x1 = nil
|
|
149
232
|
x2 = nil
|