|
Boost : |
From: Philippe Vaucher (philippe.vaucher_at_[hidden])
Date: 2007-04-30 21:53:01
On 4/30/07, Sebastian Redl <sebastian.redl_at_[hidden]> wrote:
>
> It is implemented and works. I've got a 2.6.14 kernel 64-bit Gentoo with
> a 2.5 glibc.
I found why my device_doesn't work, it's because I time a usleep(), and for
some reasons I ignore it refuses to work.
Here's a code to illustrate it :
#include <iostream>
#include <cstdio>
#include <ctime>
#include <sys/time.h>
using namespace std;
inline void test_usleep(int milliseconds)
{
usleep(milliseconds * 1000);
}
inline void do_something()
{
for(int i = 0; i < 10000; ++i)
cout << 1 << '\b' << flush;
}
int main ()
{
cout << "testing with usleep" << endl;
cout << "before: " << clock() << endl;
test_usleep(5000);
cout << "after : " << clock() << endl;
cout << "testing with code" << endl;
cout << "before: " << clock() << endl;
do_something();
cout << "after : " << clock() << endl;
return 0;
}
By me it displays :
testing with usleep
before: 0
after : 0
testing with code
before: 0
after : 60000
Is this a known behavior of std::clock() ?
Philippe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk