Boost logo

Boost Users :

From: Pedro Lamarão (pedro.lamarao_at_[hidden])
Date: 2007-03-15 22:58:16


Darren Garvey escreveu:
>
>
> On 16/03/07, *Meryl Silverburgh* <silverburgh.meryl_at_[hidden]
> <mailto:silverburgh.meryl_at_[hidden]>> wrote:
>
> Hi,
>
> If I create a boost::thread like this:
>
> boost::thread thrd1(&reader);
>
> 1. how can I sleep inside the thread? (in the method 'reader')
>
>
> I don't know of any portable way to sleep/pause the function. One
> (perhaps unhelpful) option could be std:: cin.get()? This would pause
> the thread until you hit the keyboard, although I'm unsure if any
> locking issues arise here (I don't _think_ they would).

You can block a thread by trying to lock an already locked mutex.

If you must wake the thread when a certain condition is met by the
program, just release the lock when the condition is met.

If you must wake the thread after a T amount of time, use a timed lock
with a T timeout.

--
  Pedro Lamarão

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