Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET
Apache Qpid Documentation
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
qpid
sys
Time.h
Go to the documentation of this file.
1
#ifndef _sys_Time_h
2
#define _sys_Time_h
3
4
/*
5
*
6
* Licensed to the Apache Software Foundation (ASF) under one
7
* or more contributor license agreements. See the NOTICE file
8
* distributed with this work for additional information
9
* regarding copyright ownership. The ASF licenses this file
10
* to you under the Apache License, Version 2.0 (the
11
* "License"); you may not use this file except in compliance
12
* with the License. You may obtain a copy of the License at
13
*
14
* http://www.apache.org/licenses/LICENSE-2.0
15
*
16
* Unless required by applicable law or agreed to in writing,
17
* software distributed under the License is distributed on an
18
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
* KIND, either express or implied. See the License for the
20
* specific language governing permissions and limitations
21
* under the License.
22
*
23
*/
24
25
#include "
qpid/sys/IntegerTypes.h
"
26
/*
27
* The platform defines its notion of time as a TimePrivate type. The
28
* platform's implementation knows how to handle this type.
29
*/
30
#if defined (_WIN32)
31
# include "
windows/Time.h
"
32
#else
33
# include "
posix/Time.h
"
34
#endif
35
36
#include "
qpid/CommonImportExport.h
"
37
38
#include <limits>
39
#include <iosfwd>
40
41
namespace
qpid {
42
namespace
sys {
43
44
class
Duration;
45
80
class
AbsTime
{
81
friend
class
Duration
;
82
friend
class
Condition
;
83
84
TimePrivate
timepoint;
85
86
public
:
87
88
inline
AbsTime
() : timepoint() {}
89
QPID_COMMON_EXTERN
AbsTime
(
const
AbsTime
& time0,
const
Duration
& duration);
90
// Default assignment operation fine
91
// Default copy constructor fine
92
93
QPID_COMMON_EXTERN
static
AbsTime
now
();
94
QPID_COMMON_EXTERN
static
AbsTime
FarFuture
();
95
QPID_COMMON_EXTERN
static
AbsTime
Epoch
();
96
97
bool
operator==
(
const
AbsTime
& t)
const
{
return
t.timepoint == timepoint; }
98
99
friend
bool
operator<
(
const
AbsTime
& a,
const
AbsTime
& b);
100
friend
bool
operator>
(
const
AbsTime
& a,
const
AbsTime
& b);
101
QPID_COMMON_EXTERN
friend
std::ostream&
operator <<
(std::ostream&,
const
AbsTime
&);
102
};
103
104
QPID_COMMON_EXTERN
std::ostream&
operator <<
(std::ostream&,
const
AbsTime&);
105
115
class
Duration
{
116
static
int64_t max() {
return
std::numeric_limits<int64_t>::max(); }
117
int64_t nanosecs;
118
119
friend
class
AbsTime
;
120
121
public
:
122
QPID_COMMON_INLINE_EXTERN
inline
Duration
(int64_t time0 = 0);
123
QPID_COMMON_EXTERN
explicit
Duration
(
const
AbsTime
& start,
const
AbsTime
& finish);
124
inline
operator
int64_t()
const
;
125
};
126
127
std::ostream&
operator <<
(std::ostream&,
const
Duration
&);
128
129
inline
AbsTime
now
() {
return
AbsTime::now
(); }
130
131
inline
bool
operator<
(
const
AbsTime
& a,
const
AbsTime
& b)
132
{
return
a.timepoint < b.timepoint; }
133
inline
bool
operator>
(
const
AbsTime
& a,
const
AbsTime
& b)
134
{
return
a.timepoint > b.timepoint; }
135
136
Duration::Duration
(int64_t time0) :
137
nanosecs(time0)
138
{}
139
140
Duration::operator int64_t()
const
141
{
return
nanosecs; }
142
144
const
Duration
TIME_SEC
= 1000*1000*1000;
146
const
Duration
TIME_MSEC
= 1000*1000;
148
const
Duration
TIME_USEC
= 1000;
150
const
Duration
TIME_NSEC
= 1;
151
153
const
Duration
TIME_INFINITE
= std::numeric_limits<int64_t>::max();
154
156
const
AbsTime
EPOCH
=
AbsTime::Epoch
();
157
159
const
AbsTime
FAR_FUTURE
=
AbsTime::FarFuture
();
160
162
QPID_COMMON_EXTERN
void
sleep
(
int
secs);
163
165
QPID_COMMON_EXTERN
void
usleep
(uint64_t usecs);
166
168
void
outputFormattedNow
(std::ostream&);
169
171
void
outputHiresNow
(std::ostream&);
172
173
}}
174
175
#endif
Qpid C++ API Reference
Generated on Thu Jun 13 2013 for Qpid C++ Client API by
1.8.1.1