A Small, Portable Lock-Free API

Contents

MintPack

MintPack is a portable collection of data structures and modules.

To use MintPack in your project, add the top-level include/ folder to your include paths, and compile and link with a lib build from the source in the src/mintpack/ folder. There’s a CMakeLists.txt located there, so you can use CMake to generate this lib for you. See the test suite for some examples of how it’s used.

At this point, it’s recommended that you just browse the source, header files and test cases to get more information on how to use these data structures and modules.

Lightweight Logger

#include <mintpack/lwlogger.h>

A lightweight logging system, identical to the one described in this blog post, but made portable using Mintomic.

Pseudorandom Number Generator

#include <mintpack/random.h>

Implements Random, a self-seeding pseudorandom number generator with excellent pseudorandom distribution. It passes all 144 tests in TestU01’s Crush suite. Unlike rand, it returns values that are uniformly distributed in the complete range of 32-bit integers. Unlike many pseudorandom number generators, you don’t have to seed it, yet two instances of Random are extremely unlikely to generate the same sequence. It uses MintSystem services to help accomplish this.

Random::generate32 generates a pseudorandom uint32_t, while Random::generateUnique32 is guaranteed to return a unique value for up to 4,294,967,296 calls, at which point it loops. Not thread-safe.

Thread Synchronizer

#include <mintpack/threadsynchronizer.h>

Spawns two or more threads using the same entry point function, and as much as possible, tries to kick them off simultaneously, ideally on different CPU cores.

CPU Time Waster

#include <mintpack/timewaster.h>

Performs tiny, random amounts of busy work on the CPU. Suitable for the experiment described in this blog post.