Discussion:
inconvenient for boost::thread::sleep
Christian Henning
2005-10-04 21:26:09 UTC
Permalink
Why not just write a wrapper function to make it as easy as you want?

Like:

void sleep_seconds( unsigned int nSeconds )
{
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
xt.sec += nSeconds; // change xt to next second
boost::thread::sleep(xt);
}

Christian
Mauricio Gomes
2005-10-05 18:59:39 UTC
Permalink
"Make commonly used things easy make rare difficult things possible".

In my opinion something like:

/// Current thread sleep.
void sleep (unsigned int microseconds);

It is the most common use and providing a standard library version of
this is, in my opinion, a good thing because:
1. Makes it easy for novices to use it.
2. Makes it more convenient for the experienced.

I am with RocWood, I think an API should be simple, even obvious for
the simple commonly used stuff.

Best regards,
MaurĂ­cio Gomes
Pensar Digital
55-11-4121-6287 (Brazil)
Post by Christian Henning
Why not just write a wrapper function to make it as easy as you want?
void sleep_seconds( unsigned int nSeconds )
{
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
xt.sec += nSeconds; // change xt to next second
boost::thread::sleep(xt);
}
Christian
_______________________________________________
Boost-users mailing list
http://lists.boost.org/mailman/listinfo.cgi/boost-users
boost::thread::sleep, IMHO, it's too inconvenient.

RocWood wrote:
I get these example code to sleep 1 second,
{
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
xt.sec += 1; // change xt to next second
boost::thread::sleep(xt);
}
and, only 1 line in another platform(origianl plaform or java)
{
sleep(1000);
}

hmmm...
Too inconvenient, and, to make things worse, quite a heavy calling.

Is there any suggestion for me?
Thanks.
Matt Amato
2005-10-04 13:27:55 UTC
Permalink
The thread library is still in heavy development. There has been
some dispute as the best way to handle sleeping. For now, you can
either do it the boost way, or simply use the lower level sleep call.
I currently use the lower level sleep call in many circumstances, and
will switch over when boost has a more convenient and efficient way of
doing it.
Post by Mauricio Gomes
boost::thread::sleep, IMHO, it's too inconvenient.
I get these example code to sleep 1 second,
{
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
xt.sec += 1; // change xt to next second
boost::thread::sleep(xt);
}
and, only 1 line in another platform(origianl plaform or java)
{
sleep(1000);
}
hmmm...
Too inconvenient, and, to make things worse, quite a heavy calling.
Is there any suggestion for me?
Thanks.
_______________________________________________
Boost-users mailing list
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Continue reading on narkive:
Search results for 'inconvenient for boost::thread::sleep' (Questions and Answers)
421
replies
what can i use as a electricity alternative?
started 2013-07-30 10:54:08 UTC
alternative fuel vehicles
Loading...