GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> PBS / V2-12-1 > pbs / sun-gcc
#include <PBS/RW_comdefs.h>
#include <PBS/TOC_comdefs.h>
Typedefs | |
typedef struct _RWF_ctl | RWF_ctl |
Typedef for struct _RWF_ctl, the RWF control handle. | |
Functions | |
int | RWF_sizeof (void) |
Returns the size, in bytes, of an RWF control handle. | |
int | RWF_init (RWF_ctl *rwf, RW_type type, void *ctx, RW_get_cb get, RW_free_cb free) |
Initializes the RWF control structure. | |
int | RWF_free (RWF_ctl *rwf, void *resource, void *amount) |
Frees a resource, potentially waking up a task pending on an RWF_getW() or RWF_getW_toc(). | |
void * | RWF_get (RWF_ctl *rwf, void *amount) |
Attempts to allocate a resource using the provided free routine. Whether the resource is available or not, this routine returns immediately with the return value of the get routine. See RWF_getW() and RWF_getW_toc() for versions that implement waiting. | |
void * | RWF_getW (RWF_ctl *rwf, void *amount) |
Attempts to allocate a resource using the provided get routine. This routine blocks until the get routine returns a non-NULL value. If nowaiting is desired, see RW_get(). If a waiting with a timeout is desired, see RW_getW_toc(). | |
void * | RWF_getW_toc (RWF_ctl *rwf, void *amount, const TOC *toc) |
Attempts to allocate a resource using the provided get routine. This routine blocks until the get routine returns a non-NULL value or until the timeout period expires. If nowaiting is desired, see RW_get(). If a waiting with no timeout is desired, see RW_getW_toc(). | |
int | RWF_destroy (RWF_ctl *rwf) |
Destroys an RWF control handle, returning any resources garnered by the RWF_init() routine. |
CVS $Id: RWF.h,v 1.3 2011/03/24 23:05:44 apw Exp $
Q_head q; int status; struct q_blk { Q_node *node; int buf[2]; } blks[2], *blk; RWF_ctl *rwf = MBA_alloc (RWF_sizeof ()) / * Initialize the resource Q and make some block available * / Q_init (&q); Q_insert (&q, &blks[0].node); Q_insert (&q, &blks[1].node); / * Initialize the RWF control block * / RWF_init (rwf, RW_K_TYPE_BLOCKING_FIFO_WTO, &q, Q_remove, Q_insert); . / * Allocate a block * / blk = RWF_getW (rwf, NOT_NEEDED); . . / * Free the block * / status = RWF_free (rwf, blk, NOT_NEEDED);
int RWF_destroy | ( | RWF_ctl * | rwf | ) |
Destroys an RWF control handle, returning any resources garnered by the RWF_init() routine.
rwf | The RWF control handle to destroy. |
References _RWF_ctl::rw, and RW_destroy().
int RWF_free | ( | RWF_ctl * | rwf, | |
void * | resource, | |||
void * | amount | |||
) |
Frees a resource, potentially waking up a task pending on an RWF_getW() or RWF_getW_toc().
rwf | The RWF handle | |
resource | The resource being freed. | |
amount | Typically the amount being freed. |
References _RWF_ctl::ctx, _RWF_ctl::free, _RWF_ctl::rw, and RW_free().
void* RWF_get | ( | RWF_ctl * | rwf, | |
void * | amount | |||
) |
Attempts to allocate a resource using the provided free routine. Whether the resource is available or not, this routine returns immediately with the return value of the get routine. See RWF_getW() and RWF_getW_toc() for versions that implement waiting.
rwf | The RWF handle | |
amount | The amount of the resource being requested. |
While the name of the amount parameter is suggestive, it is, in fact, just a void *, so the get routine may make any use of it that it pleases.
References _RWF_ctl::ctx, _RWF_ctl::get, _RWF_ctl::rw, and RW_get().
void* RWF_getW | ( | RWF_ctl * | rwf, | |
void * | amount | |||
) |
Attempts to allocate a resource using the provided get routine. This routine blocks until the get routine returns a non-NULL value. If nowaiting is desired, see RW_get(). If a waiting with a timeout is desired, see RW_getW_toc().
rwf | The RWF handle | |
amount | The amount of the resource being requested. |
While the name of the amount parameter is suggestive, it is, in fact, just a void *, so the get routine may make any use of it that it pleases.
References _RWF_ctl::ctx, _RWF_ctl::get, _RWF_ctl::rw, and RW_getW().
Attempts to allocate a resource using the provided get routine. This routine blocks until the get routine returns a non-NULL value or until the timeout period expires. If nowaiting is desired, see RW_get(). If a waiting with no timeout is desired, see RW_getW_toc().
rwf | The RWF handle | |
amount | The amount of the resource being requested. | |
toc | The timeout control structure. TOC_NOWAIT and TOC_FOREVER may be specified. |
While the name of the amount parameter is suggestive, it is, in fact, just a void *, so the get routine may make any use of it that it pleases.
References _RWF_ctl::ctx, _RWF_ctl::get, _RWF_ctl::rw, and RW_getW_toc().
int RWF_init | ( | RWF_ctl * | rwf, | |
RW_type | type, | |||
void * | ctx, | |||
RW_get_cb | get, | |||
RW_free_cb | free | |||
) |
Initializes the RWF control structure.
rwf | The RWF structure to initialize | |
type | The type of RW to create, see RW_type for details. | |
ctx | A context parameter passed as the first argument to both the get and free routines. | |
get | A user provide 'get' routine. The function signature is |
void *resource = (*get)(void *ctx, void *amount);
A successful allocation returns resource as non-NULL. Typically ctx is a context parameter and amount is the amount of the resource being requested.
free | User provide callback routine to implement the actual freeing of the resource. The function signature is |
(*free)(void *ctx, void *resource, void *amount);
where typically the ctx provides context to the free routine, the resource is a pointer to the resource being freed, and amount is the amount of the resource being freed.
Note that while the amount parameter name is suggestive that this represents the amount of a resource gathered, it is, in fact, just a void *, so the user is free to pass any 32-bit value that he wishes. Again, typically the freer will be handed the resource parameter and the amount parameter and be expected to just pass them on to RW_free().
References _RWF_ctl::ctx, _RWF_ctl::free, _RWF_ctl::get, _RWF_ctl::rw, and RW_init().
int RWF_sizeof | ( | void | ) |
Returns the size, in bytes, of an RWF control handle.