Method: ConcurrentWorker::Worker#req

Defined in:
lib/concurrent_worker/worker.rb

#req(*args, &work_block) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/concurrent_worker/worker.rb', line 166

def req(*args, &work_block)
  @req_mutex.synchronize do
    unless @state == :run
      run
    end
    @req_counter.wait_until_less_than(@snd_queue_max) if @snd_queue_max > 0
    begin 
      @req_counter.push([args, work_block])
      send_req([args, work_block])
      true
    rescue ClosedQueueError, IOError
      false
    end
  end
end