Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Time Requirements

Deprecated

As of Boost 1.50.0, the Boost.Thread library uses Boost.Chrono library for all operations that require a time out as defined in the standard c++11. These include (but are not limited to):

The time related functions introduced in Boost 1.35.0, using the Boost.Date_Time library are deprecated. These include (but are not limited to):

For the overloads that accept an absolute time parameter, an object of type boost::system_time is required. Typically, this will be obtained by adding a duration to the current time, obtained with a call to boost::get_system_time(). e.g.

boost::system_time const timeout=boost::get_system_time() + boost::posix_time::milliseconds(500);

extern bool done;
extern boost::mutex m;
extern boost::condition_variable cond;

boost::unique_lock<boost::mutex> lk(m);
while(!done)
{
    if(!cond.timed_wait(lk,timeout))
    {
        throw "timed out";
    }
}

For the overloads that accept a TimeDuration parameter, an object of any type that meets the Boost.Date_Time Time Duration requirements can be used, e.g.

boost::this_thread::sleep(boost::posix_time::milliseconds(25));

boost::mutex m;
if(m.timed_lock(boost::posix_time::nanoseconds(100)))
{
    //  ...
}
#include <boost/thread/thread_time.hpp>

typedef boost::posix_time::ptime system_time;

See the documentation for boost::posix_time::ptime in the Boost.Date_Time library.

#include <boost/thread/thread_time.hpp>

system_time get_system_time();

Returns:

The current time.

Throws:

Nothing.


PrevUpHomeNext