title: Coroutine-local variable in boost
body: <p>Im searching for something similar to thread-local variables, but for boost::corotine (actually i use boost:asio::spawn). Consider following code:</p>
  
  <pre><code>void coroutine_work(boost::asio::yield_context yield) {
      async_foo( yield );
      some_function();
  }
  void some_function() {
      fprintf(log_fd, "%s Some function called", the_magic_request_id);
  }
  </code></pre>
  
  <p>I want to set this <code>the_magic_request_id</code> to some value when request is initialized, which will serve like "current request id".</p>
  
  <p>Without this, i must pass <code>the_magic_request_id</code> to every function and every module which do logging in project. <code>some_function</code> is just an example, actually i have many classes, they do different work, but all of them require <code>yield_context</code> and <code>the_magic_request_id</code> in order to create an instance. I want to simplify interfaces for these classes.</p>
  
  <p>Probably its possible to set "on_sleep" and "on_resume" hooks, which will set a global variable? Or boost::coroutine already have some ready-to-user mechanics for this? Did not found something usable in the docs.</p>