dispenso 1.4.1
A library for task parallelism
Loading...
Searching...
No Matches
Getting Started

This guide walks through the core features of dispenso with working examples. Each section includes a complete, compilable example that you can build and run.

Installation

See the README for installation instructions. Dispenso requires C++14 and CMake 3.12+.

To build the examples:

mkdir build && cd build
cmake .. -DDISPENSO_BUILD_EXAMPLES=ON
make

Basic Concepts

Thread Pools

At the heart of dispenso is the ThreadPool. A thread pool manages a set of worker threads that execute tasks. You can use the global thread pool or create your own:

// Use the global thread pool (recommended for most cases)
dispenso::ThreadPool& pool = dispenso::globalThreadPool();
// Or create a custom pool with a specific number of threads
dispenso::ThreadPool myPool(4); // 4 worker threads

Task Sets

A TaskSet groups related tasks and provides a way to wait for their completion:

dispenso::TaskSet taskSet(dispenso::globalThreadPool());
taskSet.schedule([]() { /* task 1 */ });
taskSet.schedule([]() { /* task 2 */ });
taskSet.wait(); // Block until all tasks complete

Your First Parallel Loop

The simplest way to parallelize work is with parallel_for. It distributes loop iterations across available threads.