title: C++ synchronization and exception handling in cross threads
body: <p>I am using boost library for threading and synchronization in my application. </p>
  
  <p>First of all I must say exceptions within threads on synchronization is compilitey new thing for me. 
  In any case below is the pseudo code what I want to achieve. I want synchronized threads to throw same exception that MAY have been thrown from the thread doing notify. How can I achieve this?</p>
  
  <p>Could not find any topics from Stack Overflow regarding exception throwing with cross thread interaction using boost threading model </p>
  
  <p>Many thanks in advance!</p>
  
  <pre><code>// mutex and scondition variable for the problem
  mutable boost::mutex conditionMutex;
  mutable boost::condition_variable condition;
  
  inline void doTheThing() const {
  
     if (noone doing the thing) {
        try {
            doIt()
            // I succeeded
            failed = false;
            condition.notify_all();
        }
        catch (...) {
            // I failed to do it
            failed = true;
            condition.notify_all();
            throw
        }
    else {
        boost::mutex::scoped_lock lock(conditionMutex);
        condition.wait(lock);
        if (failed) {
            // throw the same exception that was thrown from 
            // thread doing notify_all
         }
    }
  </code></pre>
  
  <p>}</p>