Class: Eventr::Publisher

Inherits:
SupervisedObject show all
Defined in:
lib/eventr/actors.rb

Instance Attribute Summary

Attributes inherited from SupervisedObject

#on_exception

Instance Method Summary collapse

Methods inherited from SupervisedObject

#application, #sleep_time_from_backoff, #start, #start_application_thread, #start_supervisor_thread, #stop, #supervisor, #threads

Constructor Details

#initialize(&block) ⇒ Publisher

Returns a new instance of Publisher.



123
124
125
126
# File 'lib/eventr/actors.rb', line 123

def initialize(&block)
  @block   = block || method(:default_loop)
  @events  = Queue.new
end

Instance Method Details

#mainObject



133
134
135
# File 'lib/eventr/actors.rb', line 133

def main
  block.call(events)
end

#pop(non_block = false) ⇒ Object Also known as: shift



128
129
130
# File 'lib/eventr/actors.rb', line 128

def pop(non_block = false)
  events.pop(non_block)
end

#push(event) ⇒ Object Also known as: publish



137
138
139
# File 'lib/eventr/actors.rb', line 137

def push(event)
  @events << event
end