/* ** (c) COPYRIGHT MIT 1995. ** Please first read the full copyright statement in the file COPYRIGH. */
This module provides an event registry and a multi-threaded event loop. An application may use this module for:
#ifndef HTEVTLST_H #define HTEVTLST_H #include "sysdep.h" #include "HTEvent.h" #include "HTReq.h"
#if defined(WWW_WIN_ASYNC) || defined(WWW_WIN_DLL) extern BOOL HTEventList_winHandle (HTRequest * request); extern BOOL HTEventList_setWinHandle (HWND window, unsigned long message); extern HWND HTEventList_getWinHandle (unsigned long * pMessage); extern LRESULT CALLBACK AsyncWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); #endif
For a given socket, reqister a request structure, a set of operations, a HTEventCallback function, and a priority. For this implementation, we allow only a single HTEventCallback function for all operations. and the priority field is ignored.
extern HTEvent_registerCallback HTEventList_register;
Remove the registered information for the specified socket for the actions specified in ops. if no actions remain after the unregister, the registered info is deleted, and, if the socket has been registered for notification, the HTEventCallback will be invoked.
extern HTEvent_unregisterCallback HTEventList_unregister;
Unregister all sockets. N.B. we just remove them for our internal data structures: it is up to the application to actually close the socket.
extern int HTEventList_unregisterAll (void);
Callbacks can be looked up or dispatched based on the socket and operation (read/write/oob)
extern int HTEventList_dispatch (SOCKET s, HTEventType type, ms_t now); extern HTEvent * HTEventList_lookup (SOCKET s, HTEventType type);
This function sets the timeout for sockets in the select()
call
and registers a timeout function that is called if select times out. This
does only works on NON windows platforms as we need to poll for the console
on windows If tv = NULL
then timeout is disabled. Default is
no timeout. If always=YES then the callback is called at all times,
if NO then only when Library sockets are active. Returns YES if OK else NO.
#if 0 typedef int HTEventTimeout (HTRequest *); extern BOOL HTEventList_registerTimeout (struct timeval *tp, HTRequest * request, HTEventTimeout *tcbf, BOOL always); #endif
extern BOOL HTEventInit (void); extern BOOL HTEventTerminate (void);
That is, we wait for activity from one of our registered channels, and dispatch on that. Under Windows/NT, we must treat the console and sockets as distinct. That means we can't avoid a busy wait, but we do our best.
extern int HTEventList_loop (HTRequest * request);
Stops the (select based) event loop. The function does not guarantee that all requests have terminated. This is for the app to do
extern void HTEventList_stopLoop (void);
#endif /* HTEVTLST_H */