Run boost asio io_service forever
<p>I call <code>boost::asio::io_service::run()</code> and it returns immediately since it has no jobs to do.<br>
A different thread will queue work later on, but I don't want the <code>run</code> thread to exit.<br>
On solution is to busy wait on run:</p>

<pre><code>while(true) service.run();
</code></pre>

<p>But that would waste CPU when there is no work to do.<br>
Another way is to wait on an event that is raised every time something is queued to the service.<br>
This way has a race: If one thread stops doing work and then a second thread posts work and raises the event before the first has a chance to wait on it, the first would wait forever.<br>
I would rather avoid that and have the service know when there is work to do.<br>
Is it possible to do something like:</p>

<pre><code>while(true)
{
    service.wait_for_work();
    service.run();
}
</code></pre>