Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::thread] using futures
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2011-05-09 17:00:49


Kazz <sfx810_at_[hidden]> writes:

> Thanks for quick reply.
> Now I understand that you can only set value once for a promise. How can we
> modify the existing example, that which ever worker thread has finished and
> called the  set_value(), the next set_value() call gets ignored. One solution 
> (plz correct me here if wrong)  could be to wrap both set_value() with try
> catch block. Is there any other solution to get a final result from multiple or
> thread pools and once the result is obtained, discarding further calls to
> set_value() ?

Using try/catch is the most straightforward way to do this.

Anthony

-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net