Skip to content

Commit 658ef56

Browse files
fzakariapitr-ch
authored andcommitted
Simply make queue always false when @synchronous
1 parent c92d11e commit 658ef56

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,8 @@ def ns_limited_queue?
154154
def ns_execute(*args, &task)
155155
ns_reset_if_forked
156156

157-
assigned_worker = ns_assign_worker(*args, &task)
158-
if assigned_worker
157+
if ns_assign_worker(*args, &task) || ns_enqueue(*args, &task)
159158
@scheduled_task_count += 1
160-
elsif !@synchronous
161-
ns_enqueue(*args, &task)
162159
else
163160
handle_fallback(*args, &task)
164161
end
@@ -213,6 +210,10 @@ def ns_assign_worker(*args, &task)
213210
#
214211
# @!visibility private
215212
def ns_enqueue(*args, &task)
213+
if @synchronous
214+
return false
215+
end
216+
216217
if !ns_limited_queue? || @queue.size < @max_queue
217218
@queue << [task, args]
218219
true

0 commit comments

Comments
 (0)