Author Topic: Support for wait_for_any?  (Read 54305 times)

Kevin Scarr

  • Newbie
  • *
  • Posts: 1
    • View Profile
Support for wait_for_any?
« on: January 01, 2012, 12:59:08 AM »
Hello

I realise that the C++11(?) standard probably does not include this facility, however the futures implementation in Boost.Thread has a "wait_for_any()" facility and I was wondering if just::thread's futures also supported something similar (ie am I missing something basic)?

Alternatively, are then any suggestions for rolling my own?? By which (of course) I am hoping for a concrete example :)

Right now, I have had to revert to the futures implementation in Boost.Thread although I still use just::thread for core thread support. Just some background: I have a pool of worker threads storage in a std::list< shared_ptr<task> > and I need the main thread to wait in case one of them explodes. Normal termination involves waking the main thread and actively stopping & join()ing the threads.

Happy New Year to all!
Kevin

Anthony Williams

  • Administrator
  • Full Member
  • *****
  • Posts: 103
    • View Profile
    • just::thread C++ Thread Library
Re: Support for wait_for_any?
« Reply #1 on: January 03, 2012, 10:21:56 AM »
Just::Thread doesn't support wait_for_any() at the moment. As you say, it's not something required by C++11, and the Boost.Thread implementation imposes overhead on the futures even if they are not used in wait_for_any.

It's something I'm considering adding when I can think of a low-overhead implementation.