Written for multi-thread configurations. You can have multiple producers and consumers operating on the FIFO. The size of the FIFO is set at runtime. Use mulle-fifo if your require only a dual-thread solution.
There is a locking and a non-locking variant.
Release Version | Release Notes |
---|---|
RELEASENOTES |
void _mulle_pointermultififo_init( struct mulle_pointermultififo *p,
unsigned int size,
struct mulle_allocator *allocator)
Call ..._init
to initalize the FIFO for use. Specify a size for the FIFO.
A FIFO must be at least two entries sized. Tip: Make the FIFO at least as
big as the expected number of threads competing for access.
void _mulle_pointermultififo_done( struct mulle_pointermultififo *p)
Call ..._done
to free the FIFO when no other thread needs it. This is
necessary to avoid leaks.
void *_mulle_pointermultififo_read_barrier( struct mulle_pointermultififo *p)
Read from the FIFO. Will return NULL if empty, so will not block. Will put up a memory barrier to ensure that the memory pointed to by the returned pointer is valid.
int _mulle_pointermultififo_write( struct mulle_pointermultififo *p,
void *pointer)
Write to the FIFO. Will return -1 if full, 0 on success, so will not block.
You can not store NULL pointers or ~0
pointers into the FIFO.
If the FIFO is full your write will return with an error. If the FIFO is empty on read you will get a NULL pointer.
This project is a component of the mulle-core library. As such you usually will not add or install it
individually, unless you specifically do not want to link against
mulle-core
.
Use mulle-sde to add mulle-multififo to your project:
mulle-sde add github:mulle-concurrent/mulle-multififo
To only add the sources of mulle-multififo with dependency sources use clib:
clib install --out src/mulle-concurrent mulle-concurrent/mulle-multififo
Add -isystem src/mulle-concurrent
to your CFLAGS
and compile all the sources that were downloaded with your project.
Use mulle-sde to build and install mulle-multififo and all dependencies:
mulle-sde install --prefix /usr/local \
https://github.com/mulle-concurrent/mulle-multififo/archive/latest.tar.gz
Install the requirements:
Requirements | Description |
---|---|
mulle-thread | π Cross-platform thread/mutex/tss/atomic operations in C |
mulle-allocator | π Flexible C memory allocation scheme |
Download the latest tar or zip archive and unpack it.
Install mulle-multififo into /usr/local
with cmake:
cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_PREFIX_PATH=/usr/local \
-DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release &&
cmake --install build --config Release
Nat! for Mulle kybernetiK