This looks like nth reincarnation of "reactor". It implements the (poll()/select()/WaitForMultipleObjects()) functionality.
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include "sofia-sip/su.h"
#include "sofia-sip/su_wait.h"
#include "sofia-sip/su_alloc.h"
Include dependency graph for su_wait.c:
Functions | |
void | su_wait_init (su_wait_t dst[1]) |
Initialize a wait object. | |
int | su_wait_create (su_wait_t *newwait, su_socket_t socket, int events) |
Create a wait object. | |
int | su_wait_destroy (su_wait_t *waitobj) |
Destroy a wait object. | |
int | su_wait (su_wait_t waits[], unsigned n, su_duration_t timeout) |
Wait for multiple events. | |
int | su_wait_events (su_wait_t *waitobj, su_socket_t s) |
Get events. | |
int | su_wait_mask (su_wait_t *waitobj, su_socket_t s, int events) |
Set event mask. |
int su_wait | ( | su_wait_t | waits[], | |
unsigned | n, | |||
su_duration_t | timeout | |||
) |
Wait for multiple events.
The function su_wait() blocks until an event specified by wait objects in wait array. If timeout is not SU_WAIT_FOREVER, a timeout occurs after timeout milliseconds.
In Unix, this is poll()
or select()
.
In Windows, this is WSAWaitForMultipleEvents()
.
waits | array of wait objects | |
n | number of wait objects in array waits | |
timeout | timeout in milliseconds |
Index | of the signaled wait object, if any, | |
SU_WAIT_TIMEOUT | if timeout occurred, or | |
-1 | upon an error. |
int su_wait_create | ( | su_wait_t * | newwait, | |
su_socket_t | socket, | |||
int | events | |||
) |
Create a wait object.
The function su_wait_create() creates a new su_wait_t object for an socket, with given events. The new wait object is assigned to the newwait parameter.
There can be only one wait object per socket. (This is a limitation or feature of WinSock interface; the limitation is not enforced on other platforms).
As a side-effect the socket is put into non-blocking mode when wait object is created.
newwait | the newly created wait object (output) | |
socket | socket | |
events | mask for events that can signal this wait object |
0 | if the call was successful, | |
-1 | upon an error. |
int su_wait_destroy | ( | su_wait_t * | waitobj | ) |
Destroy a wait object.
The function su_wait_destroy() destroys a su_wait_t object.
waitobj | pointer to wait object |
0 | when successful, | |
-1 | upon an error. |
int su_wait_events | ( | su_wait_t * | waitobj, | |
su_socket_t | s | |||
) |
Get events.
The function su_wait_events() returns an mask describing events occurred.
waitobj | pointer to wait object | |
s | socket |
void su_wait_init | ( | su_wait_t | dst[1] | ) |
Initialize a wait object.
The function su_wait_init initializes a memory area of a su_wait_t object.
int su_wait_mask | ( | su_wait_t * | waitobj, | |
su_socket_t | s, | |||
int | events | |||
) |
Set event mask.
The function su_wait_mask() sets the mask describing events that can signal the wait object.
waitobj | pointer to wait object | |
s | socket | |
events | new event mask |
0 | when successful, | |
-1 | upon an error. |