c++ - Calling `f()` once regardless of exceptions -


my understanding may incorrect but, reading documentation call_once, appears if multiple threads calling simultaneously same once_flag , first thread throws exception, 1 of other threads have callable called (and forth until 1 callable returns without throwing).

my question is, if have multiple thread same callable , want callable called once regardless of exception , want know exception, have no choice this:

void call_really_just_once() {     std::exception_ptr e;      std::call_once(some_once_flag_, [&]     {         try         {             may_throw();         }         catch(...)         {             e = std::current_exception();         }     });      if(e)     {         std::rethrow_exception(e);     } } 


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -