iceoryx_hoofs
Eclipse iceoryx inter-process-communication (IPC) middleware basic building blocks
README
Eclipse iceoryx hoofs overview
The iceoryx hoofs (Handy Objects Optimised For Safety) are our basic building blocks - the foundation of iceoryx. There are a wide variety of building blocks grouped together in categories or namespace, depending on where or how they are used.
Categories
Namespace |
Short Description |
|---|---|
Since we are not allowed to use C++17 as well as the heap or exceptions we implemented constructs like |
|
You should never use concurrent constructs like |
|
Certain code patterns which are repeating themselves all over the code are abstracted and stored in here. At the moment we only have the creation pattern which will be removed in a future release. |
|
The central error handler in iceoryx for cases when no sane further execution is possible, e.g. |
|
The logger used by iceoryx. |
|
Posix constructs like shared memory, threads or semaphores are not used directly in our code base. We abstracted them so that they are following the RAII (Resource Acquisition Is Initialization) idiom and other good practices from the C++ community. |
|
Time units for duration and string literals. |
|
other |
There are even more namespaces inside the iceoryx hoofs but they will either become obsolete in the future, will be integrated into existing names or are established as another namespace and documented here. We are unsure where they will end up in the future. |
Structure
The following sections have a column labeled internal to indicate that the API
is not stable and can change anytime. You should never rely on it and there is no
support if it is used and breaks your code after an update.
The column maybe obsolete marks classes which can be removed anytime soon.
CXX
This contains STL constructs which are not part of the C++14 standard as well as convenience
constructs like the NewType. Since the module re-implements some STL constructs,
the C++ STL coding guidelines are used for all files in this module, to help the user
to have a painless transition from the official STL types to ours.
The API should also be identical to the corresponding STL types but we have to make
exceptions here. For instance, we do not throw exceptions, try to avoid undefined behavior
and we do not use dynamic memory. In these cases we adjusted the API to our use case.
Most of the headers are providing some example code on how the class should be used.
class/file |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
Implements |
||
|
C++17 and C++20 attributes are sometimes available through compiler extensions. The attribute macros defined in here (like |
||
|
Converting a number into a string is easy, converting it back can be hard. You can use functions like |
||
|
Polling based timer to check for an elapsed deadline. |
||
|
Our base class used in error handling. Every function which can fail should return an expected. With this the user knows that this function can fail and that they have to do some kind of error handling. We got inspired by the C++ expected proposal and by the rust error handling concept. |
||
|
Implementation of C++17 filesystem features for instance |
||
|
Heap and exception free, relocatable implementation of |
||
|
A stack-based |
||
|
C++11 implementation of the next-gen C++ feature |
||
|
Constructs to easily add functional interfaces like |
||
|
This is an abstraction of the C++ RAII idiom. Sometimes you have constructs where you would like to perform a certain task on creation and then again when they are getting out of scope, this is where |
||
|
Implementations of C++ Core Guideline concepts like |
||
|
Heap and exception free, relocatable implementation of |
||
|
X |
Constructs a callback from a pointer to a specific object and a pointer to a method of that object, also as |
|
|
C++11 implementation of Haskells NewType-pattern. |
||
|
C++11 implementation of the C++17 feature |
||
|
i |
X |
Simplistic re-implementation of an |
|
Acquires memory on the stack for placement new instantiations. All classes must inherit from a base class which has to be known at compile time but the class itself does not have to be known - only the size. |
||
|
i |
Basic building block for classes which are needing some kind of reference counting like a |
|
|
Base for |
||
|
Helper function to limit lifetime of static or global variables to a scope |
||
|
X |
Implements a simple serialization concept for classes based on the idea presented here ISOCPP serialization. |
|
|
i |
X |
Templated helper functions to create a fake |
|
Stack implementation with simple push/pop interface. |
||
|
i |
Untyped aligned static storage. |
|
|
i |
A |
|
|
Heap and exception free implementation of |
||
|
Extended support for evaluating types on compile-time. |
||
|
Declares essential building block types like |
||
|
i |
Monotonic increasing IDs within a process. |
|
|
Provides a heap-less unique ptr implementation, unlike the STL |
||
|
C++11 implementation of the C++17 feature |
||
|
A queue which wraps multiple variants of Queues (FiFo, SoFi, ResizeableLockFreeQueue) |
||
|
Heap and exception free implementation of |
Concurrent
If you have to write concurrent code, never use concurrency constructs like mutex, atomic, thread, semaphore, etc. directly. Most of the use cases can be solved by using an ActiveObject which uses as building block our FiFo or a
queue which is thread-safe when combined with smart_lock. To learn more about active objects see Prefer Using Active Objects Instead Of Naked Threads.
class |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
i |
X |
Active object base skeleton implementation inspired by Prefer Using Active Objects Instead Of Naked Threads |
|
i |
Single producer, single consumer lock-free FiFo |
|
|
Multi producer, multi consumer lock-free FiFo with ringbuffer like overflow handling |
||
|
i |
Lock-free LIFO based index manager (lock-free free list). One building block of our memory manager. After construction it contains the indices {0 … n} which you can acquire and release. |
|
|
i |
Periodically executes a callable specified by the template parameter in a configurable time interval. |
|
|
Resizeable variant of the |
||
|
i |
Creates arbitrary thread safe constructs which then can be used like smart pointers. If some STL type should be thread safe use the smart_lock to create the thread safe version in one line. Based on some ideas presented in Wrapping C++ Member Function Calls |
|
|
i |
Single producer, single consumer lock-free safely overflowing FiFo (SoFi). |
|
|
i |
Thread Aware exChange Ownership (TACO). Solution if you would like to use |
|
|
i |
X |
Queue with a |
attribute overview of the available Queues:
Data Structure |
Shared Memory usable |
Thread-Safe |
Lock-Free |
Concurrent Producers : Consumers |
Bounded Capacity |
Data Type Restriction |
Use Case |
|---|---|---|---|---|---|---|---|
|
Yes |
Yes |
Yes |
1:1 |
Yes |
Copyable |
FIFO Data transfer |
|
Yes |
Yes |
Yes |
n:m |
Yes |
Copyable or Movable |
lock-free transfer of arbitrary data between multiple contexts in FIFO order with overflow handling (ringbuffer) |
|
Yes |
Yes |
Yes |
n:m |
Yes |
int32 |
manage memory access, LIFO order |
|
Yes |
Yes |
No |
n/a |
n/a |
None |
Wrapper to make classes thread-safe (by using a lock) |
|
Yes |
Yes |
Yes |
1:1 |
Yes |
Trivially Copyable |
lock-free transfer of small data (e.g. pointers) between two contexts in FIFO order with overflow handling (ringbuffer) |
|
Yes |
Yes |
Yes |
n:m |
Yes |
Copyable or Movable |
Resizeable variant of the |
|
Yes |
Yes |
Yes |
n:m |
Yes |
Copyable or Movable |
fast lock-free exchange data between threads |
|
No |
Yes |
No |
n:m |
Yes |
Copyable |
Process events in a blocking way |
Design pattern
class |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
X |
When implementing resource handling classes which follow the RAII idiom we may have to throw exceptions inside the constructor. As an alternative to exceptions we have the creation pattern, a specialized factory which returns the object inside of an |
Error handling
The error handler is a central instance for collecting all errors and react to them. The error-handling.hpp contains a list of all error enum values. The error handler has different error levels, for more information see error-handling.md
class |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
Free function to call the error handler with a defined error and an error level, see header file for practical example. |
||
|
i |
error handler class only for testing purposes, should not be used directly |
Log
For information about how to use the logger API see error-handling.md
class |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
POSIX wrapper
We abstract POSIX resources following the RAII idiom and by using our Creation pattern. Try to exclusively use these abstractions or add a new one when using POSIX resources like semaphores, shared memory, etc.
class |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
i |
Interface for Access Control Lists (ACL). |
|
|
File lock C++ wrapping class. |
||
|
Shared memory based ipc channel. Mainly a |
||
|
i |
Helper types used by the |
|
|
i |
Interface for Message Queues, see ManPage mq_overview. |
|
|
i |
Mutex interface, see ManPage pthread_mutex_lock. |
|
|
Rights and user management interface. |
||
|
Wrapper around C and POSIX function calls which performs a full error handling. Additionally, this wrapper makes sure that |
||
|
Helper class for signal handler registration. |
||
|
Batteries included signal handling with polling and optional blocking wait for |
||
|
Semaphore interface, see ManPage sem_overview |
||
|
i |
Helper class for the |
|
|
i |
Abstraction of |
|
|
i |
Abstraction of shared memory, see ManPage shm_overview and helper class for the |
|
|
i |
Creates and maps existing shared memory into the application. |
|
|
i |
Collection of free functions which acquire system information like the page-size. |
|
|
Wrapper for pthread functions like |
||
|
X |
Interface for the posix timer, see ManPage timer_create. |
|
|
i |
Interface for unix domain sockets. |
Units
Never use physical properties like speed or time directly as integer or float in your code.
Otherwise you encounter problems like this function void setTimeout(int timeout). What is the unit of the argument, seconds? minutes? If you use Duration you see it directly in the code.
void setTimeout(const Duration & timeout);
setTimeout(11_s); // 11 seconds
setTimeout(5_ms); // 5 milliseconds
class |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
i |
Represents the unit time, is convertible to |
objectpool
class |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
i |
Container which stores raw objects without calling the ctor of the objects. |
graphs
class |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
i |
Creates and manages a directed graph. |
|
|
i |
Like the |
file-reader
class |
internal |
maybe obsolete |
description |
|---|---|---|---|
|
i |
X |
Wrapper for opening files and reading them. |