class Concurrent::RubyThreadPoolExecutor::Worker
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rbs class Concurrent::RubyThreadPoolExecutor::Worker def <<: (Array[Proc] message) -> Thread::Queue def create_worker: (Thread::Queue queue, Concurrent::FixedThreadPool pool, Integer idletime) -> Thread def run_task: (Concurrent::FixedThreadPool pool, Proc task, Array[] args) -> untyped end
@!visibility private
def <<(message)
Experimental RBS support (using type sampling data from the type_fusion
project).
def <<: (Array | message) -> Thread::Queue
This signature was generated using 4 samples from 2 applications.
def <<(message) @queue << message end
def create_worker(queue, pool, idletime)
Experimental RBS support (using type sampling data from the type_fusion
project).
def create_worker: (Thread::Queue queue, Concurrent::FixedThreadPool pool, Integer idletime) -> Thread
This signature was generated using 1 sample from 1 application.
def create_worker(queue, pool, idletime) Thread.new(queue, pool, idletime) do |my_queue, my_pool, my_idletime| catch(:stop) do loop do case message = my_queue.pop when :stop my_pool.remove_busy_worker(self) throw :stop else task, args = message run_task my_pool, task, args my_pool.ready_worker(self, Concurrent.monotonic_time) end end end end end
def initialize(pool, id)
def initialize(pool, id) # instance variables accessed only under pool's lock so no need to sync here again @queue = Queue.new @pool = pool @thread = create_worker @queue, pool, pool.idletime if @thread.respond_to?(:name=) @thread.name = [pool.name, 'worker', id].compact.join('-') end end
def kill
def kill @thread.kill end
def run_task(pool, task, args)
Experimental RBS support (using type sampling data from the type_fusion
project).
def run_task: (Concurrent::FixedThreadPool pool, Proc task, args) -> untyped
This signature was generated using 2 samples from 1 application.
def run_task(pool, task, args) task.call(*args) pool.worker_task_completed rescue => ex # let it fail log DEBUG, ex rescue Exception => ex log ERROR, ex pool.worker_died(self) throw :stop end
def stop
def stop @queue << :stop end