Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_cbuf.c File Reference
#include "ocs_os.h"
#include "ocs_array.h"

Go to the source code of this file.

Data Structures

struct  ocs_cbuf_t
 

Functions

ocs_cbuf_t * ocs_cbuf_alloc (ocs_os_handle_t os, uint32_t entry_count)
 Initialize a circular buffer queue. More...
 
void ocs_cbuf_free (ocs_cbuf_t *cbuf)
 Free a circular buffer. More...
 
void * ocs_cbuf_get (ocs_cbuf_t *cbuf, int32_t timeout_usec)
 Get pointer to buffer. More...
 
int32_t ocs_cbuf_put (ocs_cbuf_t *cbuf, void *elem)
 write a buffer More...
 
int32_t ocs_cbuf_prime (ocs_cbuf_t *cbuf, ocs_array_t *array)
 Prime a circular buffer data. More...
 

Function Details

ocs_cbuf_t* ocs_cbuf_alloc ( ocs_os_handle_t  os,
uint32_t  entry_count 
)

Initialize a circular buffer queue.

A circular buffer with producer/consumer API is allocated

Parameters
osOS handle
entry_countcount of entries
Returns
returns pointer to circular buffer, or NULL

Definition at line 65 of file ocs_cbuf.c.

void ocs_cbuf_free ( ocs_cbuf_t *  cbuf)

Free a circular buffer.

The memory resources of a circular buffer are free'd

Parameters
cbufpointer to circular buffer
Returns
none

Definition at line 103 of file ocs_cbuf.c.

void* ocs_cbuf_get ( ocs_cbuf_t *  cbuf,
int32_t  timeout_usec 
)

Get pointer to buffer.

Wait for a buffer to become available, and return a pointer to the buffer.

Parameters
cbufpointer to circular buffer
timeout_usectimeout in microseconds
Returns
pointer to buffer, or NULL if timeout

Definition at line 126 of file ocs_cbuf.c.

int32_t ocs_cbuf_prime ( ocs_cbuf_t *  cbuf,
ocs_array_t *  array 
)

Prime a circular buffer data.

Post array buffers to a circular buffer

Parameters
cbufpointer to circular buffer
arraypointer to buffer array
Returns
returns 0 for success, a negative error code value for failure.

Definition at line 182 of file ocs_cbuf.c.

int32_t ocs_cbuf_put ( ocs_cbuf_t *  cbuf,
void *  elem 
)

write a buffer

The buffer is written to the circular buffer.

Parameters
cbufpointer to circular buffer
elempointer to entry
Returns
returns 0 for success, a negative error code value for failure.

Definition at line 153 of file ocs_cbuf.c.