Boost logo

Boost Users :

From: Kutch, Patrick G (patrick.g.kutch_at_[hidden])
Date: 2004-08-03 19:21:59


Not a problem.

It looks as if it goes into the # elif defined(BOOST_HAS_NANOSLEEP)
section.

Patrick Kutch
Life is too short to drink bad coffee.

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Michael
Glassford
Sent: Tuesday, August 03, 2004 4:20 PM
To: boost-users_at_[hidden]
Subject: [Boost-users] Re: Looking for some help with
boost::thread::sleep()

Kutch, Patrick G wrote:

> Has nobody else experienced this?

Sorry, I forgot all about answering your original post.

If you look at the thread::sleep() method, it looks like the following;
can you tell me which path it's taking (there are several options for
pthreads) when you have the problem?

void thread::sleep(const xtime& xt)
{
     for (int foo=0; foo < 5; ++foo)
     {
#if defined(BOOST_HAS_WINTHREADS)
         int milliseconds;
         to_duration(xt, milliseconds);
         Sleep(milliseconds);
#elif defined(BOOST_HAS_PTHREADS)
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
         timespec ts;
         to_timespec_duration(xt, ts);
         int res = 0;
         res = pthread_delay_np(&ts);
         assert(res == 0);
# elif defined(BOOST_HAS_NANOSLEEP)
         timespec ts;
         to_timespec_duration(xt, ts);

         // nanosleep takes a timespec that is an offset, not
         // an absolute time.
         nanosleep(&ts, 0);
# else
         mutex mx;
         mutex::scoped_lock lock(mx);
         condition cond;
         cond.timed_wait(lock, xt);
# endif
#elif defined(BOOST_HAS_MPTASKS)
         int microseconds;
         to_microduration(xt, microseconds);
         Duration lMicroseconds(kDurationMicrosecond * microseconds);
         AbsoluteTime sWakeTime(DurationToAbsolute(lMicroseconds));
         threads::mac::detail::safe_delay_until(&sWakeTime);
#endif
         xtime cur;
         xtime_get(&cur, TIME_UTC);
         if (xtime_cmp(xt, cur) <= 0)
             return;
     }
}

Mike

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net