File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ describe Fiber::ExecutionContext::GlobalQueue do
100
100
queue = Fiber ::ExecutionContext ::GlobalQueue .new(Thread ::Mutex .new)
101
101
ready = Thread ::WaitGroup .new(n)
102
102
103
- threads = Array ( Thread ).new(n) do |i |
103
+ threads = n.times.map do |i |
104
104
new_thread(" ONE-#{ i } " ) do
105
105
slept = 0
106
106
ready.done
@@ -118,7 +118,7 @@ describe Fiber::ExecutionContext::GlobalQueue do
118
118
end
119
119
end
120
120
end
121
- end
121
+ end .to_a
122
122
ready.wait
123
123
124
124
fibers.each_with_index do |fc , i |
@@ -143,7 +143,7 @@ describe Fiber::ExecutionContext::GlobalQueue do
143
143
queue = Fiber ::ExecutionContext ::GlobalQueue .new(Thread ::Mutex .new)
144
144
ready = Thread ::WaitGroup .new(n)
145
145
146
- threads = Array ( Thread ).new(n) do |i |
146
+ threads = n.times.map do |i |
147
147
new_thread(" BULK-#{ i } " ) do
148
148
slept = 0
149
149
@@ -196,7 +196,7 @@ describe Fiber::ExecutionContext::GlobalQueue do
196
196
Thread .sleep(1 .nanosecond) # don't burn CPU
197
197
end
198
198
end
199
- end
199
+ end .to_a
200
200
ready.wait
201
201
202
202
# enqueue in batches of 5
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ describe Fiber::ExecutionContext::Runnables do
196
196
Fiber ::ExecutionContext ::Runnables (16 ).new(global_queue)
197
197
end
198
198
199
- threads = Array ( Thread ).new(n) do |i |
199
+ threads = n.times.map do |i |
200
200
new_thread(" RUN-#{ i } " ) do
201
201
runnables = all_runnables[i]
202
202
slept = 0
@@ -240,7 +240,7 @@ describe Fiber::ExecutionContext::Runnables do
240
240
Thread .sleep(1 .nanosecond) # don't burn CPU
241
241
end
242
242
end
243
- end
243
+ end .to_a
244
244
ready.wait
245
245
246
246
# enqueue in batches
Original file line number Diff line number Diff line change @@ -21,7 +21,11 @@ pending_interpreted describe: Thread do
21
21
current = nil
22
22
thread = new_thread { current = Thread .current }
23
23
thread.join
24
- current.should be(thread)
24
+ {% if flag?(:execution_context ) % }
25
+ current.should be(thread.@thread )
26
+ {% else % }
27
+ current.should be(thread)
28
+ {% end % }
25
29
current.should_not be(Thread .current)
26
30
ensure
27
31
# avoids a "GC Warning: Finalization cycle" caused by *current*
Original file line number Diff line number Diff line change 1
1
{% begin % }
2
- def new_thread (name = nil , & block) : Thread
2
+ def new_thread (name = nil , & block)
3
3
{% if flag?(:execution_context ) % }
4
- ctx = Fiber ::ExecutionContext ::Isolated .new(name: name || " SPEC" ) { block.call }
5
- ctx.@thread
4
+ Fiber ::ExecutionContext ::Isolated .new(name: name || " SPEC" ) { block.call }
6
5
{% else % }
7
6
Thread .new(name) { block.call }
8
7
{% end % }
You can’t perform that action at this time.
0 commit comments