Re: Rolling your own event handler
To: email@example.com (Matthias Dalheimer)
Subject: Re: Rolling your own event handler
From: Henrik Frystyk Nielsen <firstname.lastname@example.org>
Date: Mon, 08 Jan 1996 20:49:19 -0500
From email@example.com Mon Jan 8 20: 49:32 1996
Reply-To: Henrik Frystyk Nielsen <firstname.lastname@example.org>
X-Mailer: exmh version 1.6.2 7/18/95
> the Library Architecture Manual says that it is possible to deal with events
> in three ways:
> - Preemptive mode - have every system call block. This would be just fine
> for simple test programs (for example testing proxy access/cache strategies
> - Active mode - the Library provides its own event loop which you have to call
> via HTEvent_Loop (sp?)
> - Passive mode - the application provides the event loop. This is necessary for
> me because our applications already have en event loop which cannot (because
> of its multiplatform nature) be redirected.
> Unfortunately, I have not found any code examples (the LineModeBrowser uses
> the Library's event loop) or API calls (all the API calls in HTEvntRg.h seem
> to be made for Active mode). The User's Guide contains a section on the
> Event Manager, but it is apparently 'under construction' and only contains
> of a few lines.
> Does anybody know of any examples, documentation, code snippets etc. on how
> to use preemptive and/or passive mode?
I don't have working examples of how to use an external eventloop but the plan
is that the library gets called by the eventloop when a socket discriptor is
ready (for example for reading). When the socket is blocking again then the
protocol module (which in fact is an event handler) returns to the event loop
which then waits for the socket to get ready again.
As the only API the Library uses is the event handler functions of type
HTEventHandler then the whole event loop in HTEvntrg.c can be changed with a
new implementation without affecting the rest of the Library. This is what is
called "passive mode" as the Library doesn't control the eventloop.
Remember that many platforms allow for redirection of user events to a socket.
This can for example be done by the X library in which case the internal
library eventloop can be used directly simply by registring a socket for user
Henrik Frystyk Nielsen, <email@example.com>
World-Wide Web Consortium, MIT/LCS NE43-356
545 Technology Square, Cambridge MA 02139, USA