Boost
Libraries
arrow_drop_down
Boost.Context
M
D

This Release

James Cowgill
James Cowgill
Contributor - New
Oliver Kowalke
Oliver Kowalke
Contributor
Daniel James
Daniel James
Contributor

Dependencies

Assert
Config
Pool
Predef
Smart Ptr
Thread

boost.context

boost.context is a foundational library that provides a sort of cooperative multitasking on a single thread. By providing an abstraction of the current execution state in the current thread, including the stack (with local variables) and stack pointer, all registers and CPU flags, and the instruction pointer, a execution_context instance represents a specific point in the application's execution path. This is useful for building higher-level abstractions, like coroutines, cooperative threads (userland threads) or an equivalent to C# keyword yield in C++.

A execution_context provides the means to suspend the current execution path and to transfer execution control, thereby permitting another execution_context to run on the current thread. This state full transfer mechanism enables a execution_context to suspend execution from within nested functions and, later, to resume from where it was suspended. While the execution path represented by a execution_context only runs on a single thread, it can be migrated to another thread at any given time.

A context switch between threads requires system calls (involving the OS kernel), which can cost more than thousand CPU cycles on x86 CPUs. By contrast, transferring control among them requires only fewer than hundred CPU cycles because it does not involve system calls as it is done within a single thread.

boost.context requires C++11!

All Time

Oliver Kowalke
Contributor
Marshall Clow
Marshall Clow
Contributor
Michael Johns
Contributor
Rene Rivera
Rene Rivera
Contributor
Nick Vrvilo
Nick Vrvilo
Contributor
Steven Watanabe
Steven Watanabe
Contributor
Ben Wiederhake
Ben Wiederhake
Contributor
Kohei Takahashi
Kohei Takahashi
Contributor
Timo Sandmann
Timo Sandmann
Contributor
Torkel Bjørnson-Langen
Torkel Bjørnson-Langen
Contributor
Debian User
Contributor
Aaron Gorenstein
Aaron Gorenstein
Contributor
SSE4
SSE4
Contributor
Vladimir Prus
Vladimir Prus
Contributor
Zhe Wang
Zhe Wang
Contributor
Evgeny Shapovalov
Contributor
Inseok Lee
Inseok Lee
Contributor
Debian User
Contributor
Stephen Kelly
Stephen Kelly
Contributor
Alexander 'z33ky' Hirsch
Alexander 'z33ky' Hirsch
Contributor
Jürgen Hunold
Contributor
Hartmut Kaiser
Hartmut Kaiser
Contributor
Douglas Gregor
Douglas Gregor
Contributor
Axel Ismirlian
Axel Ismirlian
Contributor
Andrey Semashev
Andrey Semashev
Contributor
Philippe Daouadi
Philippe Daouadi
Contributor