overview.qbk 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. [/
  2. Copyright Oliver Kowalke 2014.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt
  6. ]
  7. [section:overview Overview]
  8. __boost_context__ is a foundational library that provides a sort of cooperative
  9. multitasking on a single thread. By providing an abstraction of the current
  10. execution state in the current thread, including the stack (with local
  11. variables) and stack pointer, all registers and CPU flags, and the instruction
  12. pointer, a execution context represents a specific point in the application's
  13. execution path. This is useful for building higher-level abstractions, like
  14. __coroutines__, __coop_threads__ or an equivalent to
  15. [@http://msdn.microsoft.com/en-us/library/9k7k7cf0%28v=vs.80%29.aspx C# keyword __yield__]
  16. in C++.
  17. __cc__/__con__ provides the means to suspend the current execution path and to
  18. transfer execution control, thereby permitting another context to run on the
  19. current thread. This state full transfer mechanism enables a context to suspend
  20. execution from within nested functions and, later, to resume from where it was
  21. suspended. While the execution path represented by a __con__ only runs on a
  22. single thread, it can be migrated to another thread at any given time.
  23. A [@http://en.wikipedia.org/wiki/Context_switch context switch] between threads
  24. requires system calls (involving the OS kernel), which can cost more than
  25. thousand CPU cycles on x86 CPUs. By contrast, transferring control vias
  26. __cc__/__con__ requires only few CPU cycles because it does not involve system
  27. calls as it is done within a single thread.
  28. All functions and classes are contained in the namespace __context_ns__.
  29. [note This library requires C++11!]
  30. [important Windows using fcontext_t: turn off global program optimization (/GL) and change /EHsc (compiler
  31. assumes that functions declared as extern "C" never throw a C++ exception) to /EHs (tells
  32. compiler assumes that functions declared as extern "C" may throw an exception).]
  33. [endsect]