added checking of result when building demos
[urisagit/Stem.git] / Design / event_notes
CommitLineData
4536f655 1
2Events
3
4The low-level core of a Stem hub is an event-loop engine. This
5engine provides support for the common events needed in a networking
6system, including reading and writing, socket connection and
7acceptance, and timers. The Stem::Event system provides a high-level
8API to these services to the rest of the hub while it, in turn,
9relies on a lower-level event system which is currently Event.pm,
10which is available on CPAN. This design isolates the actual event
11engine used from the cells which need its services. There are plans
12to support other event engines including Perl/Tk, and creating one
13that runs on NT/Win2K.
14
15Stem::Event uses the standard Stem callback style which requires
16parameters designating the object and method to call when an event
17has been triggered. In typical Stem fashion, the method names have
18useful defaults so a Stem::Event call is made with very few
19parameters.
20
21Read and write Stem events take a required object and filehandle as
22parameters, and an optional timeout value. If the I/O is not
23completed before the timeout occurs, the timeout method is called
24instead of the normal I/O completion method. The connect and accept
25events also require an object and the appropriate socket parameters.
26The connect event can take an optional timeout which behaves
27similarly to the read/write timeout. A timer event can be created
28which will be triggered after a given delay and optionally repeated
29at a specified interval. As you would expect in an event system,
30multiple instances of all these events can be active at the same
31time.
32
33Most cells will never directly use the Stem::Event interface as there
34are higher level cells that perform commonly needed services for
35them. These include Stem::AsynchIO, Stem::Socket, and Stem::Cron.
36However, this does not stop any cell from directly calling these if
37it needs finer control over its events.
38