bbuffer.h File Reference
Bounded Buffer implementation to manage int values that supports multiple readers but only a single writer.
More...
Go to the source code of this file.
|
Typedefs |
typedef struct BNDBUF | BNDBUF |
Functions |
BNDBUF * | bb_init (unsigned int size) |
| Creates a new Bounded Buffer.
|
void | bb_del (BNDBUF *bb) |
| Destroys a Bounded Buffer.
|
int | bb_get (BNDBUF *bb) |
| Retrieve an element from the bounded buffer.
|
void | bb_add (BNDBUF *bb, int fd) |
| Add an element to the bounded buffer.
|
Detailed Description
Bounded Buffer implementation to manage int values that supports multiple readers but only a single writer.
The bbuffer module uses the sem module API to synchronize concurrent access of readers and writers to the bounded buffer.
Typedef Documentation
Opaque type of a Bounded Buffer.
Function Documentation
void bb_add |
( |
BNDBUF * |
bb, |
|
|
int |
fd | |
|
) |
| | |
Add an element to the bounded buffer.
This function adds an element to the bounded buffer. If the bounded buffer is full, the function blocks until an element is removed from the buffer.
- Parameters:
-
| bb | Handle of the bounded buffer. |
| fd | Value that shall be added to the buffer. |
Destroys a Bounded Buffer.
All resources associated with the bounded buffer are released.
- Parameters:
-
| bb | Handle of the bounded buffer that shall be freed. |
Retrieve an element from the bounded buffer.
This function removes an element from the bounded buffer. If the bounded buffer is empty, the function blocks until an element is added to the buffer.
- Parameters:
-
| bb | Handle of the bounded buffer. |
- Returns:
- the int element
BNDBUF* bb_init |
( |
unsigned int |
size |
) |
|
Creates a new Bounded Buffer.
This function creates a new bounded buffer and all the helper data structures required by the buffer, including semaphores for synchronization. If an error occurs during the initialization the implementation shall free all resources already allocated by then.
- Parameters:
-
| size | The number of integers that can be stored in the bounded buffer. |
- Returns:
- handle for the created bounded buffer, or NULL if an error occured.