File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -16,15 +16,31 @@ module Concurrent
16
16
#
17
17
# @note Intended for use primarily in testing and debugging.
18
18
class IndirectImmediateExecutor < ImmediateExecutor
19
+ # Creates a new executor
20
+ def initialize
21
+ super
22
+ @internal_executor = PerThreadExecutor . new
23
+ end
24
+
19
25
# @!macro executor_method_post
20
26
def post ( *args , &task )
27
+ raise ArgumentError . new ( "no block given" ) unless block_given?
21
28
return false unless running?
22
29
23
- executor = SingleThreadExecutor . new
24
- executor . post ( *args , &task )
25
- executor . shutdown
26
- executor . wait_for_termination
30
+ event = Concurrent ::Event . new
31
+ internal_executor . post do
32
+ begin
33
+ task . call ( *args )
34
+ ensure
35
+ event . set
36
+ end
37
+ end
38
+ event . wait
39
+
27
40
true
28
41
end
42
+
43
+ private
44
+ attr_reader :internal_executor
29
45
end
30
46
end
You can’t perform that action at this time.
0 commit comments