File tree Expand file tree Collapse file tree 2 files changed +18
-21
lines changed Expand file tree Collapse file tree 2 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -5,25 +5,17 @@ module Concurrent
5
5
before ( :each ) do
6
6
Concurrent . class_variable_set (
7
7
:@@global_fast_executor ,
8
- Concurrent ::Delay . new ( executor : :immediate ) { Concurrent ::ImmediateExecutor . new } )
8
+ Concurrent ::LazyReference . new { Concurrent ::ImmediateExecutor . new } )
9
9
Concurrent . class_variable_set (
10
10
:@@global_io_executor ,
11
- Concurrent ::Delay . new ( executor : :immediate ) { Concurrent ::ImmediateExecutor . new } )
11
+ Concurrent ::LazyReference . new { Concurrent ::ImmediateExecutor . new } )
12
12
Concurrent . class_variable_set (
13
13
:@@global_timer_set ,
14
- Concurrent ::Delay . new ( executor : :immediate ) { Concurrent ::ImmediateExecutor . new } )
14
+ Concurrent ::LazyReference . new { Concurrent ::ImmediateExecutor . new } )
15
15
end
16
16
17
17
after ( :each ) do
18
- Concurrent . class_variable_set (
19
- :@@global_fast_executor ,
20
- Concurrent ::Delay . new ( executor : :immediate ) { Concurrent . new_fast_executor } )
21
- Concurrent . class_variable_set (
22
- :@@global_io_executor ,
23
- Concurrent ::Delay . new ( executor : :immediate ) { Concurrent . new_io_executor } )
24
- Concurrent . class_variable_set (
25
- :@@global_timer_set ,
26
- Concurrent ::Delay . new ( executor : :immediate ) { Concurrent ::TimerSet . new } )
18
+ reset_gem_configuration
27
19
end
28
20
29
21
context 'global executors' do
Original file line number Diff line number Diff line change 3
3
4
4
module Concurrent
5
5
module TestHelpers
6
+
6
7
def delta ( v1 , v2 )
7
8
if block_given?
8
9
v1 = yield ( v1 )
@@ -31,19 +32,23 @@ def do_no_reset!
31
32
@do_not_reset = true
32
33
end
33
34
35
+ GLOBAL_EXECUTORS = [
36
+ [ :@@global_fast_executor , -> { LazyReference . new { Concurrent . new_fast_executor } } ] ,
37
+ [ :@@global_io_executor , -> { LazyReference . new { Concurrent . new_io_executor } } ] ,
38
+ [ :@@global_timer_set , -> { LazyReference . new { Concurrent ::TimerSet . new } } ] ,
39
+ ]
40
+
34
41
@@killed = false
35
42
36
43
def reset_gem_configuration
37
44
if @@killed
38
- Concurrent . class_variable_set (
39
- :@@global_fast_executor ,
40
- Concurrent ::Delay . new ( executor : :immediate ) { Concurrent . new_fast_executor } )
41
- Concurrent . class_variable_set (
42
- :@@global_io_executor ,
43
- Concurrent ::Delay . new ( executor : :immediate ) { Concurrent . new_io_executor } )
44
- Concurrent . class_variable_set (
45
- :@@global_timer_set ,
46
- Concurrent ::Delay . new ( executor : :immediate ) { Concurrent ::TimerSet . new } )
45
+ GLOBAL_EXECUTORS . each do |var , factory |
46
+ executor = Concurrent . class_variable_get ( var ) . value
47
+ executor . shutdown
48
+ executor . kill
49
+ executor = nil
50
+ Concurrent . class_variable_set ( var , factory . call )
51
+ end
47
52
@@killed = false
48
53
end
49
54
end
You can’t perform that action at this time.
0 commit comments