Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions lib/solid_queue/pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@ def initialize(size, on_idle: nil)
def post(execution)
available_threads.decrement

future = Concurrent::Future.new(args: [ execution ], executor: executor) do |thread_execution|
Concurrent::Promises.future_on(executor, execution) do |thread_execution|
wrap_in_app_executor do
thread_execution.perform
ensure
available_threads.increment
mutex.synchronize { on_idle.try(:call) if idle? }
end
end.on_rejection! do |e|
handle_thread_error(e)
end

future.add_observer do |_, _, error|
handle_thread_error(error) if error
end

future.execute
end

def idle_threads
Expand Down
Loading