ThinkMeta ConcurrentTasks
ThinkMeta ConcurrentTasks is a task scheduler for Windows and Linux (x64) that runs tasks on fibers. A task can wait — for another task, an event, a lock, a file read or a socket — without blocking its OS thread: the thread simply runs the next task. A handful of threads keep all cores busy while thousands of tasks wait.
What you get
- A small core — the scheduler, timers and an I/O completion port, behind a C interface in a single header (Core.h).
- A C++ module library on top of it — tasks, synchronization primitives that suspend tasks instead of threads, lock-free collections, zero-copy pipes and asynchronous files and sockets.
- Plain code that waits. A task calls
Wait()in the middle of its work, in any function on its call stack — no callbacks, noco_awaitthrough every layer.
A first look
A complete program: one task, started on a scheduler and waited for by main.
// Hello task: start a scheduler, run one task on it, wait for the task, shut down.
#include <cstdio>
#include <ThinkMeta.ConcurrentTasks/Core.h>
import ThinkMeta.ConcurrentTasks.Tasks.WaitableTask;
namespace TC = ThinkMeta::ConcurrentTasks;
// A task is an object with a Run method. WaitableTask adds Wait, so others can wait
// for it.
class HelloTask : public TC::Tasks::WaitableTask
{
public:
void Run() noexcept override { std::printf("Hello from a task\n"); }
};
int main()
{
// The main thread becomes a task too, so it can wait without blocking a
// scheduler thread.
TC::ConvertThreadToTask();
// One scheduler thread per logical processor (numberOfThreads = 0).
TC::SchedulerInfo info{};
TC::ITaskScheduler* scheduler
= TC::CreateTaskScheduler(TC::SchedulerKind::Default, &info);
if (scheduler == nullptr)
return 1;
scheduler->Start();
HelloTask task; // must outlive the task: from AddTask until it has exited
scheduler->AddTask(&task);
task.Wait(); // suspends main until Run has returned
scheduler->Stop(); // only after every task has finished
scheduler->Destroy();
TC::ConvertTaskToThread();
return 0;
}Source and project on GitHub Your first program walks through it step by step.
Performance first
The core and the library are built for speed, not to be watertight against misuse: lifetimes, queue capacities and single-waiter rules are the developer's responsibility. Read Performance first before you build on it.
Where to go next
| If you want to … | Read |
|---|---|
| understand what it is and when it pays off | What is ConcurrentTasks?, When to use it |
| build and run something | Requirements, Getting started |
| see what changed and what comes next | Release notes, Roadmap |
| know how it works | Concepts |
| solve a concrete problem | Guides and Samples |
| look up a type or function | API reference |