This is a partial response to a great set of questions from Jeff.
Here''s a
partial suggestion for an interface on which to build everything else (this
is all pseudocode, not correct Ruby):
require ''eventmachine''
# The require has the effect of automatically starting the Reactor on its
own thread.
# The reactor has a thread-safe queue attached to it.
module Eventable # for mixing into other classes
# posts an event onto the Reactor''s internal queue.
def schedule_event( target, event_code, data) {|...|
# this optional block specifies a callback.
# Not shown is the optional parameter :errback = lamba {error handler}
}
def consume_event( event_code ) {
# this block is called when the specified event type is received
}
# subscribe to signal interest in a class of events, defined *somehow*
# This can be used in conjunction with a thread pool
def subscribe_event( parms )
end
end
This module gets mixed into other classes, which will define particular
semantics for specific event_codes and targets. Of particular importance
(and underspecified here) is how this interacts with threads. We will need
to carefully define on which thread event-handlers will be called, and give
the caller a certain amount of control over that.
Next, I''ll come back with some possible classes built on this to handle
things like network connections and file i/o.
Comments?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/eventmachine-talk/attachments/20060519/0c6fc03a/attachment.htm