Skip to content

Commit b02930e

Browse files
committed
Simplify logic
1 parent 845e1d6 commit b02930e

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/concurrent-ruby/concurrent/executor/ruby_executor_service.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@ def initialize(*args, &block)
1616

1717
def post(*args, &task)
1818
raise ArgumentError.new('no block given') unless block_given?
19-
deferred_action = nil
20-
synchronize do
21-
# If the executor is shut down, reject this task
22-
unless running?
23-
deferred_action = fallback_action(*args, &task)
24-
break
19+
deferred_action = synchronize {
20+
if running?
21+
ns_execute(*args, &task)
22+
else
23+
fallback_action(*args, &task)
2524
end
26-
deferred_action = ns_execute(*args, &task)
27-
end
28-
25+
}
2926
if deferred_action
3027
deferred_action.call
3128
else

0 commit comments

Comments
 (0)