Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
qpid/sys/Time.h
Go to the documentation of this file.
00001 #ifndef _sys_Time_h
00002 #define _sys_Time_h
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  *
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 
00025 #include "qpid/sys/IntegerTypes.h"
00026 /*
00027  * The platform defines its notion of time as a TimePrivate type. The
00028  * platform's implementation knows how to handle this type.
00029  */
00030 #if defined (_WIN32)
00031 #  include "windows/Time.h"
00032 #else
00033 #  include "posix/Time.h"
00034 #endif
00035 
00036 #include "qpid/CommonImportExport.h"
00037 
00038 #include <limits>
00039 #include <iosfwd>
00040 
00041 namespace qpid {
00042 namespace sys {
00043 
00044 class Duration;
00045 
00080 class AbsTime {
00081     friend class Duration;
00082     friend class Condition;
00083 
00084     TimePrivate timepoint;
00085 
00086 public:
00087 
00088     inline AbsTime() : timepoint() {}
00089     QPID_COMMON_EXTERN AbsTime(const AbsTime& time0, const Duration& duration);
00090     // Default assignment operation fine
00091     // Default copy constructor fine
00092 
00093     QPID_COMMON_EXTERN static AbsTime now();
00094     QPID_COMMON_EXTERN static AbsTime FarFuture();
00095     QPID_COMMON_EXTERN static AbsTime Epoch();
00096 
00097     bool operator==(const AbsTime& t) const { return t.timepoint == timepoint; }
00098 
00099     friend bool operator<(const AbsTime& a, const AbsTime& b);
00100     friend bool operator>(const AbsTime& a, const AbsTime& b);
00101     QPID_COMMON_EXTERN friend std::ostream& operator << (std::ostream&, const AbsTime&);
00102 };
00103 
00104 QPID_COMMON_EXTERN std::ostream& operator << (std::ostream&, const AbsTime&);
00105 
00115 class Duration {
00116     static int64_t max() { return std::numeric_limits<int64_t>::max(); }
00117     int64_t nanosecs;
00118 
00119     friend class AbsTime;
00120 
00121 public:
00122     QPID_COMMON_INLINE_EXTERN inline Duration(int64_t time0 = 0);
00123     QPID_COMMON_EXTERN explicit Duration(const AbsTime& start, const AbsTime& finish);
00124     inline operator int64_t() const;
00125 };
00126 
00127 std::ostream& operator << (std::ostream&, const Duration&);
00128 
00129 inline AbsTime now() { return AbsTime::now(); }
00130 
00131 inline bool operator<(const AbsTime& a, const AbsTime& b)
00132 { return a.timepoint < b.timepoint; }
00133 inline bool operator>(const AbsTime& a, const AbsTime& b)
00134 { return a.timepoint > b.timepoint; }
00135 
00136 Duration::Duration(int64_t time0) :
00137     nanosecs(time0)
00138 {}
00139 
00140 Duration::operator int64_t() const
00141 { return nanosecs; }
00142 
00144 const Duration TIME_SEC  = 1000*1000*1000;
00146 const Duration TIME_MSEC = 1000*1000;
00148 const Duration TIME_USEC = 1000;
00150 const Duration TIME_NSEC = 1;
00151 
00153 const Duration TIME_INFINITE = std::numeric_limits<int64_t>::max();
00154 
00156 const AbsTime EPOCH = AbsTime::Epoch();
00157 
00159 const AbsTime FAR_FUTURE = AbsTime::FarFuture();
00160 
00162 QPID_COMMON_EXTERN void sleep(int secs);
00163 
00165 QPID_COMMON_EXTERN void usleep(uint64_t usecs);
00166 
00168 void outputFormattedNow(std::ostream&);
00169 
00171 void outputHiresNow(std::ostream&);
00172 
00173 }}
00174 
00175 #endif  

Qpid C++ API Reference
Generated on Thu Aug 23 2012 for Qpid C++ Client API by doxygen 1.7.5