An EventGenerator is a source of Events.
An EventGenerator is registered with an
EventDispatcher which repeatedly polls
all registered EventGenerators for new Events. Events are then placed on an
event queue for processing by the EventProcessor. The EventGenerator is responsible for returning
a list of Events that have occurred since the previous poll.
Users are expected to either create their own subclasses that override the
get_events method. Alternatively,
users can pass a block as part of the constructor. The block will be
executed upon each invocation of get_events by the EventDispatcher.
Creates an EventGenerator. If a block is
provided, it will be executed upon each invocation of get_events. This provides a very
simple means to creating generators.
Returns an array of events that have occurred since the last time the EventGenerator was polled. If no events have
occurred, it returns an empty array. This method should be overridden by a
concrete implementation. If a block was supplied to the constructor, it
will be executed upon invocation of this method to return an array of
Starts the EventGenerator. This method is
optional and not all implementations will need to be started. It is invoked
when the EventDispatcher is started.
Stops the EventGenerator. This method is
optional and not all implementations will need to be stopped. It is invoked
when the EventDispatcher is stopped and
has been provided to permit a clean shutdown of the framework.