uringmachine 0.6 → 0.6.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/um/um.c +21 -1
- data/lib/uringmachine/version.rb +1 -1
- data/test/run.rb +5 -0
- data/test/test_um.rb +9 -13
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 602ceb6207baea6b38287928500c73df48258ca2f8cf843f02b45fa65c591e3e
|
4
|
+
data.tar.gz: 78b2bc7a274b03e2ae51510e213be0d23911c4db102ad4ab7eee435f915bb5c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0dcbb93493c9778cf4ac12769f88611364d4e190c9e9dfa666543643e3aa3b44fa01cc49cf1ea2a1ba4798c4893b75e8b47e5b1eeac23b48bc5a6d84046e458
|
7
|
+
data.tar.gz: 5b012fcc3e7fd1a6d4e68aae58b9d099f19d5a89670772cdfdd6ef4ac76ed9781f533fd576e2b19b02c7774ba31d3ce6ee06dc590e04ce07a62e3c7fb2394191
|
data/CHANGELOG.md
CHANGED
data/ext/um/um.c
CHANGED
@@ -175,8 +175,28 @@ inline VALUE process_runqueue_op(struct um *machine, struct um_op *op) {
|
|
175
175
|
inline VALUE um_fiber_switch(struct um *machine) {
|
176
176
|
while (true) {
|
177
177
|
struct um_op *op = um_runqueue_shift(machine);
|
178
|
-
if (op)
|
178
|
+
if (op) {
|
179
|
+
// in case of a snooze, we need to prevent a situation where completions
|
180
|
+
// are not processed because the runqueue is never empty. Theoretically,
|
181
|
+
// we can still have a situation where multiple fibers are all doing a
|
182
|
+
// snooze repeatedly, which can prevent completions from being processed.
|
183
|
+
|
184
|
+
// is the op a snooze op and is this the same fiber as the current one?
|
185
|
+
if (unlikely(op->kind == OP_SCHEDULE && op->fiber == rb_fiber_current())) {
|
186
|
+
// are there any pending ops (i.e. waiting for completion)?
|
187
|
+
if (machine->pending_count > 0) {
|
188
|
+
// if yes, process completions, get runqueue head, put original op
|
189
|
+
// back on runqueue.
|
190
|
+
um_wait_for_and_process_ready_cqes(machine);
|
191
|
+
struct um_op *op2 = um_runqueue_shift(machine);
|
192
|
+
if (likely(op2 && op2 != op)) {
|
193
|
+
um_runqueue_push(machine, op);
|
194
|
+
op = op2;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
179
198
|
return process_runqueue_op(machine, op);
|
199
|
+
}
|
180
200
|
|
181
201
|
um_wait_for_and_process_ready_cqes(machine);
|
182
202
|
}
|
data/lib/uringmachine/version.rb
CHANGED
data/test/run.rb
ADDED
data/test/test_um.rb
CHANGED
@@ -917,32 +917,28 @@ class QueueTest < UMBaseTest
|
|
917
917
|
q = UM::Queue.new
|
918
918
|
buf = []
|
919
919
|
|
920
|
-
|
920
|
+
machine.spin do
|
921
921
|
buf << [1, machine.pop(q)]
|
922
|
-
machine.yield
|
923
922
|
end
|
924
923
|
|
925
|
-
machine.
|
926
|
-
|
927
|
-
f2 = Fiber.new do
|
924
|
+
machine.spin do
|
928
925
|
buf << [2, machine.pop(q)]
|
929
|
-
machine.yield
|
930
926
|
end
|
931
927
|
|
932
|
-
machine.schedule(f2, nil)
|
933
|
-
|
934
928
|
machine.snooze
|
935
929
|
assert_equal [], buf
|
930
|
+
assert_equal 2, machine.pending_count
|
936
931
|
|
937
932
|
machine.push(q, :foo)
|
938
933
|
assert_equal 1, q.count
|
939
|
-
machine.
|
934
|
+
machine.snooze
|
935
|
+
assert_equal 1, machine.pending_count
|
940
936
|
assert_equal [[1, :foo]], buf
|
941
937
|
|
942
938
|
machine.push(q, :bar)
|
943
939
|
assert_equal 1, q.count
|
944
940
|
|
945
|
-
machine.
|
941
|
+
machine.snooze
|
946
942
|
assert_equal [[1, :foo], [2, :bar]], buf
|
947
943
|
assert_equal 0, q.count
|
948
944
|
end
|
@@ -969,7 +965,7 @@ class QueueTest < UMBaseTest
|
|
969
965
|
end
|
970
966
|
machine.schedule(f2, nil)
|
971
967
|
|
972
|
-
|
968
|
+
machine.snooze
|
973
969
|
|
974
970
|
assert_equal [[1, :bar], [2, :foo]], buf.sort
|
975
971
|
assert_equal 0, q.count
|
@@ -996,12 +992,12 @@ class QueueTest < UMBaseTest
|
|
996
992
|
end
|
997
993
|
machine.schedule(f2, nil)
|
998
994
|
|
999
|
-
machine.
|
995
|
+
machine.snooze
|
1000
996
|
|
1001
997
|
assert_equal [[1, :foo]], buf
|
1002
998
|
machine.push(q, :bar)
|
1003
999
|
|
1004
|
-
machine.
|
1000
|
+
machine.snooze
|
1005
1001
|
assert_equal [[1, :foo], [2, :bar]], buf
|
1006
1002
|
end
|
1007
1003
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uringmachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/uringmachine/version.rb
|
137
137
|
- supressions/ruby.supp
|
138
138
|
- test/helper.rb
|
139
|
+
- test/run.rb
|
139
140
|
- test/test_actor.rb
|
140
141
|
- test/test_async_op.rb
|
141
142
|
- test/test_ssl.rb
|