
In message <435B34B617D19D40977CBB72A9C3463804CFF8F2@RED-MSG-53.redmond.corp.microso ft.com>, Jon Kalb <jonkalb@microsoft.com> writes
And usage as follows:
void void_task(); int int_task(); ... joiner<void> wait_for_completion = thread(void_task); joiner<int> wait_for_value = thread(int_task); ... int result = wait_for_value(); wait_for_completion();
In the code snippet above does the line "int result = wait_for_value();" block until the completion of the thread? (It must or there is no way of knowing if the value of result is valid.) Is there a way for the client to avoid the block by checking whether or not thread is completed so that the call won't block... Some sort of wait_for_value.is_done()?
Yes, the simple check to allow non-blocking behaviour is expressed as a Boolean conversion, ie if(wait_for_value) { int result = wait_for_value(); ... // do something with result now thread has completed } else { ... // do something else instead } This ability to query availability is a typical feature of future variables. Kevlin -- ____________________________________________________________ Kevlin Henney phone: +44 117 942 2990 mailto:kevlin@curbralan.com mobile: +44 7801 073 508 http://www.curbralan.com fax: +44 870 052 2289 Curbralan: Consultancy + Training + Development + Review ____________________________________________________________