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 | AI Documentation |
|---|---|---|
| RELEASENOTES | DeepWiki for mulle-multififo |
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.
mulle-multififo is a component of the mulle-core library. So in your code include the mulle-core umbrella header:
#include <mulle-core/mulle-core.h>Add mulle-core to your CMakeLists.txt with
FetchContent:
include( FetchContent)
set( MULLE__CORE_TAG "master" CACHE STRING "branch or tag to fetch mulle-core from")
FetchContent_Declare( MULLE__CORE
GIT_REPOSITORY https://github.com/mulle-core/mulle-core.git
GIT_TAG "${MULLE__CORE_TAG}")
FetchContent_MakeAvailable( MULLE__CORE)
target_link_libraries( ${PROJECT_NAME} PRIVATE mulle-core)mulle-sde add github:mulle-core/mulle-coreclib install --out src mulle-concurrent/mulle-multififoAppend src to your include path (e.g. add -isystem src to your CFLAGS)
and compile all the sources that were downloaded.
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.gzInstall 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:
PREFIX_DIR="/usr/local"
cmake -B build \
-DMULLE_SDK_PATH="${PREFIX_DIR}" \
-DCMAKE_INSTALL_PREFIX="${PREFIX_DIR}" \
-DCMAKE_PREFIX_PATH="${PREFIX_DIR}" \
-DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release &&
cmake --install build --config ReleaseNat! for Mulle kybernetiK