-
Notifications
You must be signed in to change notification settings - Fork 3
Building
This implementation is header only. Apart from standard C++20 includes there are no external dependencies needed in your application. Catch2 is used for the built-in unit tests. termbox2 is used for the optional fiber monitor. The fiber monitor test applications also use gmp.
To clone and default build all the examples, including the test monitor applications run the following. The cmake
script will download, build and test gmp
and termbox2
needed for the test monitor applications:
git clone [email protected]:fix8mt/fiber.git
cd fiber
mkdir build
cd build
cmake ..
make -j4
make test
To build the examples without the test monitor, run cmake as follows:
cmake -DBUILD_MONITOR=false ..
The example applications are built in the build directory.
Currently only gcc and clang are supported. The following table summarises how to select each when building.
Compiler | CMake invocation |
---|---|
gcc |
CXX="g++ -ggdb" CC="gcc -ggdb" cmake .. |
clang |
CXX="clang++ -ggdb" CC="clang -ggdb" cmake .. |
In CMakeLists.txt
set your include path to:
include_directories([f8fiber directory]/include)
# e.g.
set(f8fiberdir /home/dd/prog/fiber)
include_directories(${f8fiberdir}/include)
and just include:
#include <fix8/fiber.hpp>
in your application. Everything in this class is within the namespace FIX8
, so you can add:
using namespace FIX8;
Certain aspects of the build may be controlled with the following defines:
#define | Description | Default |
---|---|---|
FIX8_FIBER_DEFSTKSZ |
Default stack size for a fiber; you can override in individual fibers with fiber_params
|
131072 (128kb ) |
FIX8_FIBER_FIBERNAMELEN |
Default length of a fiber name string, including terminating null | 16 |
FIBER_NO_INSTRUMENTATION |
When defined, fiber will not contain any instrumentation variables or support any printing |
not defined |
FIBER_NO_MULTITHREADING |
When defined, fiber will not support transferring fibers between threads |
not defined |
For performance critical applications, it is recommended to define FIBER_NO_INSTRUMENTATION
and FIBER_NO_MULTITHREADING
in your source.
FIBER_NO_INSTRUMENTATION
will remove additional variables and code used to track fibers in each thread as well as printing and so forth.
FIBER_NO_MULTITHREADING
will remove the ability to transfer fibers between threads which incurs some small performance penalty.