What is Catch2?
masterSECTIONs allow for local setup and teardown code sharing within tests.repository·master·Indexed 21 days ago
https://github.com/richiesams/fibertaskinglibA C++ library for fiber-based tasking. Documentation includes build guides for Windows and Unix systems using CMake, instructions for integrating the ftl target into CMake and non-CMake projects, and comprehensive code style and naming conventions. It also details the use of Catch2 for unit testing and micro-benchmarking within the project.
SECTIONs allow for local setup and teardown code sharing within tests.If your project does not use CMake, you must manually configure your toolchain:
{FTL_ROOT}/include{FTL_ROOT}/third_party/boost_context/includeftl.libboost_context.libCommit messages must follow the Conventional Commits format to enable automatic semantic-versioning and changelog generation.
Commit Structure:
<type>[optional scope]: Summarize changes in around 50 characters or lessExample Format:
<type>[optional scope]: Summarize changes in around 50 characters or less
More detailed explanatory text, if necessary. In some contexts,
the first line is treated as the subject of the commit and the rest of
the text as the body. The blank line separating the summary from the body
is critical (unless you omit the body entirely); various tools like `log`,
`shortlog` and `rebase` can get confused if you run the two together.
Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.
Further paragraphs come after blank lines.
* Bullet points are okay, too
* Typically a hyphen or asterisk is used for the bullet, preceded
by a single space, with blank lines in between, but conventions
vary here
If you use an issue tracker, put references to them at the bottom, like this:
Resolves: #123
See also: #456, #789<type>[optional scope]: Summarize changes in around 50 characters or less
More detailed explanatory text, if necessary.
Explain the problem that this commit is solving.
Resolves: #123To ensure adherence to FiberTaskingLib's formatting conventions, it is highly recommended to use clang-format. You can configure your IDE to run it on save, or use the provided Makefile command to format the entire codebase using Docker.
Note: While the documentation uses spaces for visual consistency, actual code must use tabs for indentations. Use spaces only for alignment.
make formatClasses and structs should follow a specific layout order:
Initializer lists must start on a new line from the constructor definition, with each entry on its own line and aligned using spaces. The entire list should be indented once if the constructor has no body, or twice if it does.
class Fiber {
public:
Fiber()
: m_stack(nullptr),
m_systemPageSize(0),
m_stackSize(0),
m_context(nullptr),
m_arg(0) {
}
};class ExampleClass {
public:
// Constructors
ExampleClass();
ExampleClass(ExampleClass &&other);
public:
// Public member variables
int Width;
int Height;
private:
// Private member variables
float m_deltaTime;
public:
// Public methods
void Rotate();
private:
// Private methods
int DecrementHeight(float amount);
};To build the library on Unix-like systems, use CMake with the default Makefile generator.
build directory and run CMake.make to compile.ftl-test binary to run tests.cd /path/to/FiberTaskingLib
mkdir build
cd build
cmake ../
make -j
./tests/ftl-testAlways use braces for if, for, while, and do-while statements, even for single-line bodies. Braceless statements are highly discouraged.
a = (b + c) * d;.while (true) {.SomeFunction(a, b, c);.for (int a = 0; b < c; d++).class BusWheel : public RubberInflatable or (isNight) ? ColorMeDark() : ColorMeBright();.* or & but not after it: const char *ptr = (const char *)foobar; or int &ref = i;.template keyword and <. Place the definition on the line preceding the class/function.[]: delete[] foo;.operator keyword from the name, except for type conversion operators.namespace clause.public:, private:) inside classes.case keywords with the switch keyword. Indent the contents of the case blocks.Classes, structs, and functions should be documented using the Javadoc style, including @brief, @param, and @return tags.
/**
* @brief Adds a group of tasks to the internal queue
*
* @param numTasks The number of tasks
* @param tasks The tasks to queue
* @return An atomic counter corresponding to the task group as a whole.
*/
std::shared_ptr<std::atomic_uint> AddTasks(uint numTasks, Task *tasks);/**
* @brief Adds a group of tasks to the internal queue
*
* @param numTasks The number of tasks
* @param tasks The tasks to queue
* @return An atomic counter corresponding to the task group as a whole. Initially it will equal numTasks. When each task completes, it will be decremented.
*/
std::shared_ptr<std::atomic_uint> AddTasks(uint numTasks, Task *tasks);The recommended way to consume FiberTaskingLib is to include its source directory directly using CMake's add_subdirectory() command. Because FiberTaskingLib is a modern CMake project using target_* functions, linking to the ftl target automatically handles include directories and dependencies.
You can control the build scope using these cache variables:
FTL_BUILD_TESTS: Set to ON (default) to build tests, or OFF to skip them.FTL_BUILD_BENCHMARKS: Set to ON to build benchmarks, or OFF to skip them.Note: The provided example contains a typo in the source where FTL_BUILD_TESTS is used twice instead of FTL_BUILD_BENCHMARKS for the second option; ensure you use the correct variable name in your project.
cmake_minimum_required(VERSION 3.8)
project(MyProject)
# Disable tests and benchmarks to speed up build
set( FTL_BUILD_TESTS OFF CACHE BOOL "Disable tests" )
set( FTL_BUILD_BENCHMARKS OFF CACHE BOOL "Disable benchmarks" )
# Add FiberTaskingLib source
add_subdirectory(third_party/FiberTaskingLib)
# Create your executable
add_executable(MyProject source/main.cpp)
target_include_directories(MyProject PRIVATE include)
# Link to FiberTaskingLib (automatically handles includes)
target_link_libraries(MyProject ftl)