Boost logo

Boost Users :

From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-03-28 16:03:34


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 28 March 2008 14:28 pm, Raider wrote:
> boost::condition Condition;
> ...
>
> void Thread1()
> {
> MyCode::CreateThread2();
> boost::mutex m;
> boost::mutex::scoped_lock l(m);
> if (!Condition.timed_wait(l, make500msdelay()))
> ...
> }
>
> void Thread2()
> {
> Condition.notify_all();
> }
>
> Am I using boost::condition right way? Is `m' mutex nessesary?

It looks like you need to lock m in Thread2, to insure the notify doesn't
happen before Thread1 starts waiting on it.

- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFH7U8a5vihyNWuA4URAuNFAKCGwsTYBqVewizUOR2o2UcnCKGXwwCdH4Rp
UJOLnnuHwqfAJAmvqHcciYs=
=MLco
-----END PGP SIGNATURE-----


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