Module: ConcurrentWorker::ConcurrentThread

Defined in:
lib/concurrent_worker.rb

Instance Method Summary collapse

Instance Method Details

#cncr_blockObject



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/concurrent_worker.rb', line 224

def cncr_block
  @thread_channel = Queue.new
  @thread =  Thread.new do
    Thread.handle_interrupt(Object => :never) do
      begin
        Thread.handle_interrupt(Object => :immediate) do
          yield_base_block
        end
      ensure
        @req_counter.close
        @thread_channel.close
        call_retired_callbacks
      end
    end
  end
end

#receive_reqObject



245
246
247
# File 'lib/concurrent_worker.rb', line 245

def receive_req
  @thread_channel.pop
end

#send_req(args) ⇒ Object



241
242
243
# File 'lib/concurrent_worker.rb', line 241

def send_req(args)
  @thread_channel.push(args)
end

#send_res(args) ⇒ Object



249
250
251
# File 'lib/concurrent_worker.rb', line 249

def send_res(args)
  call_result_callbacks(args)
end

#wait_cncr_procObject



253
254
255
# File 'lib/concurrent_worker.rb', line 253

def wait_cncr_proc
  @thread && @thread.join
end