Add an event request to the event queue of a thread as the result of an asynchronous event.
CS_INT srv_event_deferred(spp, event, datap)
SRV_PROC *spp; CS_INT event; CS_VOID *datap;
A pointer to an internal thread control structure.
The event to add to the thread’s event queue.
A pointer (CS_VOID) to data supplied by the Open Server programmer. An application can retrieve the data by calling srv_thread_props with property set to SRV_T_EVENTDATA from within the event handler.
The requested event. If there was an error, -1 is returned.
Returns |
To indicate |
---|---|
The token for the requested event. |
Open Server added the new event. |
-1 |
The routine failed. |
#include <ospublic.h>
/*
** Local Prototype
*/
CS_RETCODE ex_srv_event_deferred PROTOTYPE((
SRV_PROC *spp,
CS_INT event,
CS_VOID *datap
));
/*
** EX_SRV_EVENT_DEFERRED
** Example routine to queue up a deferred event using
** srv_event_deferred. A deferred event request will
** typically be made from within interrupt-level code.
** Arguments:
** spp A pointer to the internal thread control
** structure.
** event The event to add to the thread’s queue.
** datap A pointer to data to attach to the event.
** Returns:
** CS_SUCCEED The event was sucecssfully queued.
** CS_FAIL An error was detected.
*/
CS_RETCODE ex_srv_event_deferred(spp, event, datap)
SRV_PROC *spp;
CS_INT event;
CS_VOID *datap;
{
/*
** Add a deferred event to the event queue.
*/
if (srv_event_deferred(spp, event, datap) == -1)
{
return(CS_FAIL);
}
return(CS_SUCCEED);
}
srv_event_deferred adds an event request to the event queue of a thread from interrupt-level code, such as signal delivery on UNIX or AST delivery on VMS. The event request is deferred until critical functions internal to Open Server have been completed, if any such functions were being performed when srv_event_deferred was called.
Some Open Server applications must be able to raise events from interrupt-level code. For example, if you want to raise an event within the attention handler or you are using the alarm signal in the Open Server application code, you must use srv_event_deferred instead of srv_event. srv_event_deferred ensures that critical functions, such as updating linked lists or performing internal housekeeping, are completed before the event request is acted on.
WARNING! In interrupt-level code, use srv_event_deferred instead of srv_event.
Open Server usually adds event requests to a thread’s event request queue automatically. However, you can specifically add requests with srv_event_deferred.
The following events can be added to an event queue by srv_event_deferred:
SRV_DISCONNECT
SRV_URGDISCONNECT
SRV_STOP
Programmer-defined events
srv_handle tells the Open Server which event handler to call when an event occurs. If no handler is defined for a particular event, the default event Open Server handler is called.
If the event is programmer-defined, it must be defined with srv_define_event before it can be triggered.
srv_event adds any event except SRV_STOP or SRV_START to a thread’s event queue. In the case of a SRV_STOP or SRV_START event, spp points to the internal thread control structure for the thread requesting the event.
An Open Server application cannot call any routine that does I/O from inside a user-defined event.
srv_define_event, srv_event, srv_handle, srv_thread_props, “Events”