Skip to content

About

πŸ› mulle-multififo multi-producer/multi-consumer FIFO holding `void *`

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

mulle-multififo

πŸ› mulle-multififo multi-producer/multi-consumer FIFO holding void *

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
Mulle kybernetiK tag standard: C11 apis: ansi memory: allocator threads: mpmc Build Status RELEASENOTES DeepWiki for mulle-multififo

API

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.

Documentation & Guides

Usage

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.

You are here

Overview

Add

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 a cmake project

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)

Add mulle-core to a mulle-sde project

mulle-sde add github:mulle-core/mulle-core

Embed mulle-multififo with clib

clib install --out src mulle-concurrent/mulle-multififo

Append src to your include path (e.g. add -isystem src to your CFLAGS) and compile all the sources that were downloaded.

Install

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

Manual Installation

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:

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 Release

Author

Nat! for Mulle kybernetiK

About

πŸ› mulle-multififo multi-producer/multi-consumer FIFO holding `void *`

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages