|
Boost : |
From: Maxim Egorushkin (e-maxim_at_[hidden])
Date: 2003-06-30 15:22:32
"William E. Kempf" <wekempf_at_[hidden]> wrote in message
news:1502.167.16.75.51.1056996926.squirrel_at_frodo.kempf-ville.com...
> > Speaking about the timer I ment something like that:
> >
> > typedef int milliseconds;
> >
> > class stopwatch
> > {
> > public:
> > stopwatch()
> > : started_(::GetTickCount())
> > {}
> >
> > milliseconds elapsed() const
> > {
> > return ::GetTickCount() - started_;
> > }
> >
> > private:
> > const DWORD started_;
> > };
>
> Ahh... that's not a threading concept ;).
Let me disagree here :) A couple of days ago I was implementing a user mode
task scheduler. And I had the scheduler thread updating the tasks delays 4
times per second and putting ready for execution tasks in the execution
queue. I tryed to make it portable but the problem was that I could be sure
that the scheduler thread would receive its time slice exactly every 250 ms.
To solve the problem I decided to increase the scheduler thread priority and
to measure the time the thread spent sleeping till the next time slice. I
was using boost::thread library and my solution could be implemented by
means of the library and made my code unportable. That was the rationale of
my posting.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk