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
1616 #
1717 # @note Intended for use primarily in testing and debugging.
1818 class IndirectImmediateExecutor < ImmediateExecutor
19+ # Creates a new executor
20+ def initialize
21+ super
22+ @internal_executor = PerThreadExecutor . new
23+ end
24+
1925 # @!macro executor_method_post
2026 def post ( *args , &task )
27+ raise ArgumentError . new ( "no block given" ) unless block_given?
2128 return false unless running?
2229
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+
2740 true
2841 end
42+
43+ private
44+ attr_reader :internal_executor
2945 end
3046end
You can’t perform that action at this time.
0 commit comments