title: How to use boost context correctly
body: <p>I want to implement a job system for my game engine using fibers. After searching the internet for a good c++ implementation of fibers, I found that <a href="http://www.boost.org/doc/libs/1_64_0/libs/context/doc/html/index.html" rel="nofollow noreferrer">Boost.Context</a> is a good starting point.</p>
  
  <blockquote>
    <p><strong>Update 1</strong>: I want to implement my own scheduling algorithm, thus <a href="http://www.boost.org/doc/libs/1_64_0/libs/fiber/doc/html/index.html" rel="nofollow noreferrer">Boost.Fiber</a>, <a href="http://www.boost.org/doc/libs/1_64_0/libs/coroutine/doc/html/index.html" rel="nofollow noreferrer">Boost.Coroutine</a>, <a href="http://www.boost.org/doc/libs/1_64_0/libs/coroutine2/doc/html/index.html" rel="nofollow noreferrer">Boost.Coroutine2</a> are not suitable for my implementation.</p>
  </blockquote>
  
  <p>After compiling boost for x64 architecture and trying to run the basic example from the boost <a href="http://www.boost.org/doc/libs/1_64_0/libs/context/doc/html/context/cc.html" rel="nofollow noreferrer">documentation</a> I got the following exception: </p>
  
  <blockquote>
    <p>boost::context::detail::forced_unwind at memory location</p>
  </blockquote>
  
  <p>This is the code I tried to run (Visual Studio 2015 enterprise edition, windows 7):</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost\context\continuation.hpp&gt;
  namespace ctx=boost::context;
  int main()
  {
      ctx::continuation source=ctx::callcc
      (
          [](ctx::continuation &amp;&amp; sink)
          {
              int a=0;
              int b=1;
              for(;;)
              {
                  sink=sink.resume(a);
                  auto next=a+b;
                  a=b;
                  b=next;
              }
              return std::move(sink);
          }
      );
      for (int j=0;j&lt;10;++j) {
          std::cout &lt;&lt; source.get_data&lt;int&gt;() &lt;&lt; " ";
          source=source.resume();
      }
      return 0;
  }
  </code></pre>
  
  <p>The code ran correctly (correct output: 0 1 1 2 3 5 8 13 21 34 55), but when it finished the run I got the exception. </p>
  
  <blockquote>
    <p><strong>Update 2: The exception occurs only for the release build</strong></p>
  </blockquote>
  
  <p>I want to ask two questions regarding boost context:</p>
  
  <blockquote>
    <p><strong>1)</strong> What caused the stack unwinding exception, and how to avoid it?<br><br>
    <strong>2)</strong> I found the boost documentation a bit shallow, and couldn't find any other tutorial on how to use boost context. Can you direct me
    to some good sources/tutorials about boost context?</p>
  </blockquote>