Class: Hawkei::Processor::Async

Inherits:
Object
  • Object
show all
Defined in:
lib/hawkei/processor/async.rb

Instance Method Summary collapse

Constructor Details

#initializeAsync

Returns a new instance of Async.



5
6
7
8
9
10
11
12
13
# File 'lib/hawkei/processor/async.rb', line 5

def initialize
  @queue = Queue.new
  @state_worker = Concurrent::AtomicBoolean.new(true)
  @worker = Worker.new(@queue, @state_worker)

  at_exit do
    shutdown_worker if worker_running?
  end
end

Instance Method Details

#enqueue(attributes) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/hawkei/processor/async.rb', line 15

def enqueue(attributes)
  ensure_worker_running

  @queue << attributes

  true
end