Boost logo

Boost :

From: Loïc Joly (loic.actarus.joly_at_[hidden])
Date: 2002-05-25 08:40:31

Marcus Blomenkamp wrote:
> > timed_mutex mutex (0.01); // frequency 100Hz
> > timed_mutex::lock lock(mutex);
> > while (true)
> > {
> > lock.lock();
> > doMyCalculations();
> > }
> >
> > I would like to have your feedback about this idea.
> Hi there.
> I don't think this is a good idea. First of all 'lock.lock()' will IMHO
> throw an exception if it can't acquire the mutex after the expired time.
> So there is extra logic to add. Second your interval will be roughly
> 0.01 + T(doMyCalculations) -> 105..109ms which is not as exact as it
> could be.

Sorry, but I do not understand your estimation. Could you please add
some more details ?

> A better idea would be to use a two-thread conecpt. One thread does
> nothing but signalling a condition every 10ms and the other threads just
> repeatedly waits for the condition to be signalled. This will
> definitively improve the interval precision and looks nicer/clearer IMHO.
This is roughly what I intended, except that I tried to encapsulate the
signaling thread within a special mutex.


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