1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Overview</title> 5<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../index.html" title="Chapter 1. Coroutine2"> 8<link rel="up" href="../index.html" title="Chapter 1. Coroutine2"> 9<link rel="prev" href="../index.html" title="Chapter 1. Coroutine2"> 10<link rel="next" href="intro.html" title="Introduction"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 27<a name="coroutine2.overview"></a><a class="link" href="overview.html" title="Overview">Overview</a> 28</h2></div></div></div> 29<p> 30 <span class="bold"><strong>Boost.Coroutine2</strong></span> provides templates for generalized 31 subroutines which allow suspending and resuming execution at certain locations. 32 It preserves the local state of execution and allows re-entering subroutines 33 more than once (useful if state must be kept across function calls). 34 </p> 35<p> 36 Coroutines can be viewed as a language-level construct providing a special 37 kind of control flow. 38 </p> 39<p> 40 In contrast to threads, which are pre-emptive, <span class="emphasis"><em>coroutine</em></span> 41 switches are cooperative (programmer controls when a switch will happen). The 42 kernel is not involved in the coroutine switches. 43 </p> 44<p> 45 The implementation uses <span class="bold"><strong>Boost.Context</strong></span> for 46 context switching. 47 </p> 48<p> 49 In order to use the classes and functions described here, you can either include 50 the specific headers specified by the descriptions of each class or function, 51 or include the master library header: 52 </p> 53<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">coroutine2</span><span class="special">/</span><span class="identifier">all</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 54</pre> 55<p> 56 which includes all the other headers in turn. 57 </p> 58<p> 59 All functions and classes are contained in the namespace <span class="emphasis"><em>boost::coroutines2</em></span>. 60 </p> 61<div class="note"><table border="0" summary="Note"> 62<tr> 63<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td> 64<th align="left">Note</th> 65</tr> 66<tr><td align="left" valign="top"><p> 67 This library requires C++11! 68 </p></td></tr> 69</table></div> 70<div class="important"><table border="0" summary="Important"> 71<tr> 72<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../doc/src/images/important.png"></td> 73<th align="left">Important</th> 74</tr> 75<tr><td align="left" valign="top"><p> 76 Windows using fcontext_t: turn off global program optimization (/GL) and 77 change /EHsc (compiler assumes that functions declared as extern "C" 78 never throw a C++ exception) to /EHs (tells compiler assumes that functions 79 declared as extern "C" may throw an exception). 80 </p></td></tr> 81</table></div> 82</div> 83<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 84<td align="left"></td> 85<td align="right"><div class="copyright-footer">Copyright © 2014 Oliver Kowalke<p> 86 Distributed under the Boost Software License, Version 1.0. (See accompanying 87 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 88 </p> 89</div></td> 90</tr></table> 91<hr> 92<div class="spirit-nav"> 93<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 94</div> 95</body> 96</html> 97