mirror of
https://github.com/boostorg/thread.git
synced 2026-01-23 18:12:12 +00:00
122 lines
4.8 KiB
HTML
122 lines
4.8 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link rel="stylesheet" type="text/css" href="../../../boost.css">
|
|
<title>Boost.Threads - Header <boost/thread/xtime.hpp></title>
|
|
</head>
|
|
<body link="#0000ff" vlink="#800080">
|
|
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
"header">
|
|
<tr>
|
|
<td valign="top" width="300">
|
|
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
|
|
</td>
|
|
<td valign="top">
|
|
<h1 align="center">Boost.Threads</h1>
|
|
<h2 align="center">Header <<a href="../../../boost/thread/xtime.hpp">boost/thread/xtime.hpp</a>></h2>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<hr>
|
|
<h2>Contents</h2>
|
|
<dl class="page-index">
|
|
<dt><a href="#introduction">Introduction</a></dt>
|
|
<dt><a href="#values">Values</a></dt>
|
|
<dl class="page-index">
|
|
<dt><a href="#value-spec">TIME_UTC</a></dt>
|
|
</dl>
|
|
<dt><a href="#classes">Classes</a></dt>
|
|
<dl class="page-index">
|
|
<dt><a href="#class-spec">Struct <code>xtime</code></a></dt>
|
|
<dl class="page-index">
|
|
<dt><a href="#class-xtime-synopsis">Struct <code>xtime</code> synopsis</a></dt>
|
|
</dl>
|
|
</dl>
|
|
<dt><a href="#functions">Functions</a></dt>
|
|
<dl class="page-index">
|
|
<dt><a href="#function-xtime_get"><code>xtime_get</code></a></dt>
|
|
</dl>
|
|
<dt><a href="#examples">Example(s)</a></dt>
|
|
</dl>
|
|
<hr>
|
|
<h2><a name="introduction"></a>Introduction</h2>
|
|
<p>The header <<a href="../../../boost/thread/xtime.hpp">boost/thread/xtime.hpp</a>>
|
|
defines functions and data types used to perform high-resolution time operations.
|
|
This is a temporary solution that will be replaced by a more robust time library
|
|
once available in Boost.</p>
|
|
<h2><a name="values"></a>Values</h2>
|
|
<pre><a name="value-spec"></a>
|
|
enum
|
|
{
|
|
TIME_UTC
|
|
}
|
|
</pre>
|
|
<p>The clock type for Coordinated Universal Time (UTC). The epoch for this clock
|
|
type is 1970-01-01 00:00:00. This is the only clock type supported by <b>Boost.Threads</b>.</p>
|
|
<h2><a name="classes"></a>Classes</h2>
|
|
<h3><a name="class-xtime"></a>Struct <code>xtime</code></h3>
|
|
<p>The <code>xtime</code> type is used to represent a point on some time scale
|
|
or a duration in time. This type may be proposed for the C standard by Markus
|
|
Kuhn. <b>Boost.Threads</b> provides only a very minimal implementation of this
|
|
proposal and it's expected that a full implementation (or some other time
|
|
library) will be provided in Boost as a separate library, at which time <b>Boost.Threads</b>
|
|
will deprecate its implementation.</p>
|
|
<h4><a name="class-xtime-synopsis"></a>Struct <code>xtime</code> synopsis</h4>
|
|
<pre>
|
|
namespace boost
|
|
{
|
|
struct xtime
|
|
{
|
|
#if defined(BOOST_NO_INT64_T)
|
|
int_fast32_t sec;
|
|
#else
|
|
int_fast64_t sec;
|
|
#endif
|
|
int_fast32_t nsec;
|
|
};
|
|
};
|
|
</pre>
|
|
<h2><a name="functions"></a>Functions</h2>
|
|
<pre>
|
|
<a name="function-xtime_get"></a>int xtime_get(struct xtime* xtp, int clock_type);
|
|
</pre>
|
|
<dl class="function-semantics">
|
|
<dt><b>Postconditions:</b> <code>xtp</code> represents the current point in
|
|
time as a duration since the epoch specified by the <code> clock_type</code>.</dt>
|
|
<dt><b>Returns:</b> <code>clock_type</code> if successful, otherwise 0.</dt>
|
|
<dt><b>Note:</b> The resolution is implementation specific. For many implementations
|
|
the best resolution of time is far more than one nanosecond, and even when
|
|
the resolution is reasonably good, the latency of a call to <code>xtime_get()</code>
|
|
may be significant. For maximum portability, avoid durations of less than
|
|
one second.</dt>
|
|
</dl>
|
|
<h2><a name="examples"></a>Example(s)</h2>
|
|
<pre>
|
|
#include <a href="../../../boost/thread/thread.hpp"><boost/thread/thread.hpp></a>
|
|
#include <a href="../../../boost/thread/tss.hpp"><boost/thread/xtime.hpp></a>
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
boost::xtime xt;
|
|
boost::xtime_get(&XT, boost::TIME_UTC);
|
|
xt.sec += 1;
|
|
boost::thread::sleep(XT); // Sleep for 1 second
|
|
}
|
|
</pre>
|
|
<hr>
|
|
<p>Revised
|
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
|
05 November, 2001
|
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
|
</p>
|
|
<p><i>© Copyright <a href="mailto:wekempf@cox.net">William E. Kempf</a> 2001-2002.
|
|
All Rights Reserved.</i></p>
|
|
<p>Permission to use, copy, modify, distribute and sell this software and its
|
|
documentation for any purpose is hereby granted without fee, provided that the
|
|
above copyright notice appear in all copies and that both that copyright notice
|
|
and this permission notice appear in supporting documentation. William E. Kempf
|
|
makes no representations about the suitability of this software for any purpose.
|
|
It is provided "as is" without express or implied warranty.</p>
|
|
</body>
|
|
</html>
|