Skip to content

Commit 3dc0e87

Browse files
committed
Making Event and Future fields volatile to remove few more synchronizations
1 parent 32162e0 commit 3dc0e87

File tree

2 files changed

+177
-221
lines changed

2 files changed

+177
-221
lines changed

examples/benchmark_new_futures.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@
1616
x.compare!
1717
end
1818

19-
2019
Benchmark.ips(time, warmup) do |x|
21-
ohead = Concurrent::Promise.execute { 1 }
2220
x.report('graph-old') do
23-
head = ohead
21+
head = Concurrent::Promise.execute { 1 }
2422
branch1 = head.then(&:succ)
2523
branch2 = head.then(&:succ).then(&:succ)
2624
Concurrent::Promise.zip(branch1, branch2).then { |(a, b)| a + b }.value!
2725
end
28-
nhead = Concurrent.future { 1 }
2926
x.report('graph-new') do
30-
head = nhead
27+
head = Concurrent.future { 1 }
3128
branch1 = head.then(&:succ)
3229
branch2 = head.then(&:succ).then(&:succ)
3330
(branch1 + branch2).then { |(a, b)| a + b }.value!

0 commit comments

Comments
 (0)