From: Loïc Joly (loic.actarus.joly_at_[hidden])
Date: 2002-05-25 04:06:01
This is my first post in this list, even if I have been reading it
partially for a couple of months.
I recently had a look at the thread library, I was surprised to see that
one of the features I use most often wasn't in the library, namely to be
able to have a periodical thread.
The function thread::sleep does not fullfill my need, as can be seen in
the following example :
I want to run some calculations at 100Hz, those calculations
take between 1ms and 5ms, if I just want to put a sleep after
my calculations are done, I do not know how long it should wait
(between 9ms and 5ms), unless I measure how long my calculations
actually were, which I find a tedious task.
I have used myself for some time the traditionnal way to define that by
calling a function of the type :
typedef void ThreadEntryFunction(void *data);
void setPeriodicalThread (double period, ThreadEntryFunction f, void
But I recently found another idiom that I found much easyer to use. It
needs the creation of a mutex class that automatically unlock itself at
a specified frequency, and provides access to a class following the Lock
timed_mutex mutex (0.01); // frequency 100Hz
I would like to have your feedback about this idea.
-- Loïc Joly
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk