Boost logo

Boost :

Subject: Re: [boost] [threads / signals2] Win events replace by boost signals (threadsafe)
From: Fu ji (fujimailing_at_[hidden])
Date: 2015-03-25 03:57:05

I read about condition variable and it's also not the best idea, because we
can receive signal only if we actually wait in this time. For example:

void setcondvar()
    std::cout << "Set" << std::endl;
    std::cout << "After" << std::endl;

int main()
    boost::mutex CondMutex;

    boost::thread t1(setcondvar);

    std::cout << "Before wait" << std::endl;

    boost::unique_lock<boost::mutex> lock(CondMutex);
    bool result = cond.timed_wait(lock,

    std::cout << result;

return 0;

and we have 0 as result. Probably i should write some wrapper on cond
variable if i would like to have this functionality.

2015-03-24 23:40 GMT+01:00 Gavin Lambert <gavinl_at_[hidden]>:

> On 24/03/2015 22:28, Fu ji wrote:
>> Condition variable can be a really good solution to my problem, I have
>> only
>> problem with WaitForMultipleObjects because with cond_var I have to check
>> all "events" in loop with cond.timed_wait. There is a better solution ?
> If the events are intended to signal that data is available somewhere,
> then you could consider replacing them with futures instead, which can
> supply the data at the same time. There is a way to wait for one or all of
> a set of multiple futures, although not with a timeout.
> _______________________________________________
> Unsubscribe & other changes:
> mailman/listinfo.cgi/boost

Boost list run by bdawes at, gregod at, cpdaniel at, john at