Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | Related Pages

Event API

handle different aspects of the MqS event-queue More...

Typedefs

typedef void(* MqEventF )(ContextSP)
 a prototype for a EventChecking procedure
typedef void(* EventCreateF )(ContextSP)
 prototype for a EventQueueing procedure

Enumerations

enum  MqWaitOnEventE { MQ_WAIT = (1 << 0), MQ_FOREVER = (1 << 1) }
 wait for an event? More...

Functions

MQ_EXTERN MqErrorE MqEventCheck (MqSP const msgque, const MqIoSelectE type, struct timeval *timeout, EventCreateF proc)
 check for a new event on all MqS objects currently defined.
MQ_EXTERN MqErrorE MqProcessEvent (MqSP const msgque, const time_t timeout, const MqWaitOnEventE wait)
 waiting for an incoming packet on the single file-handle belonging to the MqS object.

Detailed Description

handle different aspects of the MqS event-queue

the event-queue have to be linked into an existing event-processing infrastructure. the linking is done by defining prototypes for two independent procedures:


Typedef Documentation

typedef void( * EventCreateF)(ContextSP)
 

prototype for a EventQueueing procedure

Example:
tclFreiburg 2.0 event-handling procedures
void eventQueue(ContextSP  const context) {
    MqEventS *event = (MqEventS*) ckalloc(sizeof(MqEventS));
    event->header.proc = eventProcess;
    event->context = context;
    Tcl_QueueEvent((Tcl_Event*)event, TCL_QUEUE_TAIL);
}
void tclEventCheck(ClientData clientData, int flags) {
    if (!(flags & TCL_FILE_EVENTS)) return;
    struct timeval tv = {0L, 0L};
    MqEventCheck(NULL, MQ_SELECT_RECV, &tv, eventQueue);
}

Definition at line 607 of file types.h.


Enumeration Type Documentation

enum MqWaitOnEventE
 

wait for an event?

Enumeration values:
MQ_WAIT  wait for new event
MQ_FOREVER  wait forever

Definition at line 262 of file types.h.


Function Documentation

MQ_EXTERN MqErrorE MqEventCheck MqSP const   msgque,
const MqIoSelectE  type,
struct timeval *  timeout,
EventCreateF  proc
 

check for a new event on all MqS objects currently defined.

the checking is done by do a 'select' on all file-handles owned by the MqS objects and invoking the EventCreateF procedure to add new events into an external event-queue

Change for 2.0:
use an MqS object as first parameter
Parameters:
msgque  link to an MqS object
type  specify the type of select (e.g. MQ_SELECT_RECV or MQ_SELECT_SEND)
timeout  specify a timeout value in seconds
proc  the procedure to add events into an external event-queue

MQ_EXTERN MqErrorE MqProcessEvent MqSP const   msgque,
const time_t  timeout,
const MqWaitOnEventE  wait
 

waiting for an incoming packet on the single file-handle belonging to the MqS object.

this procedure is used to wait for (e.g. MqWaitOnEventE == MQ_WAIT) or check (e.g. no MQ_WAIT) the file-handle for an incoming event. if an event occurs the header of the Msgque packet is parsed and the according service-handle is called. if MqWaitOnEventE == MQ_FOREVER the procedure will never return, accept for error processing.

Example:
tclFreiburg 2.0 event processing procedure
static int
eventProcess(Tcl_Event * evPtr, int flags)
{
  if (!(flags & TCL_FILE_EVENTS)) return 0;
  MqSP  const msgque = (((MqEventS*)evPtr)->context)->msgque;
  // check if event evPtr has disappeared until queuing 'eventQueue'
  MqErrorCheck(MqProcessEvent(msgque, MQ_TIMEOUT, !MQ_WAIT));
  return 1;

error:
  TclErrorGetResult (msgque);
  Tcl_BackgroundError (msgque->myCtx->interp);
  return 1;
}
Parameters:
msgque  link to the MqS object
timeout  a timeout value is seconds
wait  some options for customization (e.g. MQ_WAIT or MQ_FOREVER)


Generated on Tue Nov 23 16:13:06 2004 for libFreiburg by  doxygen 1.3.8-20040928