NAME

cxInputAdd - register a file descripter for monitoring

C SPECIFICATION

#include <cx/ModuleCommand.h>

void *cxInputAdd( int fd, cxInputMask condition, cxInputCallbackProc callback, void *client_data)

FORTRAN SPECIFICATION

None

PARAMETERS

fd
The Unix file descripter to monitor. Unix file descriptors are small integers zero or greater and are generally the return value from an open() system call.
condition
This routine can be used to monitor a file descripter for any combination of conditions: available input, writability, or an exception condition. The value of the condition argument can be cx_InputReadMask , cx_InputWriteMask , or cx_InputExceptMask. These correspond to the read set, write set, and exception set in the Unix select(2) system call. Though these values contain the word Mask, they cannot be combined with an inclusive ``or'' operation.
callback
The user callback routine. This subroutine is called by the control wrapper when one of the conditions is satisfied. See below for the calling sequence used by cxInputAdd.
client_data
Arbitrary client data. This value is passed to the user callback routine when the condition occurs.

DESCRIPTION

cxInputAdd implements a facility whereby a module can request that it be informed when a particular Unix file descripter is ready for reading or writing, or has suffered some exception condition. This gives the module writer access to the module scheduler, allowing modification of the scheduler's select(2) Unix system call.

The return value of this function is an opaque handle that can be used in a subsequent call to cxInputRemove for removing the monitoring function.

When the specified condition occurs, the Control Wrapper will call the function named in the callback argument to cxInputAdd. This function is assumed to have three formal arguments, as follows:

The argument client_data is the value passed in to cxInputAdd. Argument fd is the Unix file descripter that is affected. Argument handle is the return value from cxInputAdd that corresponds to this activity. It may be used in a call to cxInputRemove if conditions warrant.

The action of calling a callback procedure is not equivalent to actually firing the module. If the callback routine decides that the module should be fired based on new information resulting from the file descriptor activity, it should use cxFireASAP to schedule the future firing of the module.

Because of the synchronous nature of the firing behavior of IRIS Explorer modules, a file descripter callback procedure will never be called when the module is firing. These callbacks are only called when the module is quiescent.

This facility works for both X and non-X modules.

EXAMPLE

The following code fragment shows an example of how this routine might be used within a module:

SEE ALSO

select(2), cxInputRemove(3E), XtAddInput(3X)
Last modified: Mon Nov 18 13:49:59 GMT 1996
[ Documentation Home ]
© The Numerical Algorithms Group Ltd, Oxford UK. 1996