mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 03:03:23 +02:00
added Clock class which provides a monotonic clock on most platforms and is now used by Poco::Timer, Poco::Stopwatch, Poco::TimedNotificationQueue and Poco::UtilTimer to avoid issues when the system time is changed
This commit is contained in:
@@ -5037,6 +5037,10 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\Clock.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTime.cpp"
|
||||
>
|
||||
@@ -5233,6 +5237,10 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Clock.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DateTime.h"
|
||||
>
|
||||
|
@@ -926,6 +926,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\UUID.cpp" />
|
||||
<ClCompile Include="src\UUIDGenerator.cpp" />
|
||||
<ClCompile Include="src\Clock.cpp" />
|
||||
<ClCompile Include="src\DateTime.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormat.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatter.cpp" />
|
||||
@@ -1227,6 +1228,7 @@
|
||||
<ClInclude Include="include\Poco\SharedMemory_WIN32.h" />
|
||||
<ClInclude Include="include\Poco\UUID.h" />
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h" />
|
||||
<ClInclude Include="include\Poco\Clock.h" />
|
||||
<ClInclude Include="include\Poco\DateTime.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormat.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormatter.h" />
|
||||
|
@@ -756,6 +756,9 @@
|
||||
<ClCompile Include="src\UUIDGenerator.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Clock.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTime.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -1580,6 +1583,9 @@
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Clock.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\DateTime.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -932,6 +932,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\UUID.cpp" />
|
||||
<ClCompile Include="src\UUIDGenerator.cpp" />
|
||||
<ClCompile Include="src\Clock.cpp" />
|
||||
<ClCompile Include="src\DateTime.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormat.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatter.cpp" />
|
||||
@@ -1234,6 +1235,7 @@
|
||||
<ClInclude Include="include\Poco\SharedMemory_WIN32.h" />
|
||||
<ClInclude Include="include\Poco\UUID.h" />
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h" />
|
||||
<ClInclude Include="include\Poco\Clock.h" />
|
||||
<ClInclude Include="include\Poco\DateTime.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormat.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormatter.h" />
|
||||
|
@@ -774,6 +774,9 @@
|
||||
<ClCompile Include="src\UUIDGenerator.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Clock.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTime.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -1610,6 +1613,9 @@
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Clock.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\DateTime.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -932,6 +932,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\UUID.cpp" />
|
||||
<ClCompile Include="src\UUIDGenerator.cpp" />
|
||||
<ClCompile Include="src\Clock.cpp" />
|
||||
<ClCompile Include="src\DateTime.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormat.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatter.cpp" />
|
||||
@@ -1234,6 +1235,7 @@
|
||||
<ClInclude Include="include\Poco\SharedMemory_WIN32.h" />
|
||||
<ClInclude Include="include\Poco\UUID.h" />
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h" />
|
||||
<ClInclude Include="include\Poco\Clock.h" />
|
||||
<ClInclude Include="include\Poco\DateTime.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormat.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormatter.h" />
|
||||
|
@@ -774,6 +774,9 @@
|
||||
<ClCompile Include="src\UUIDGenerator.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Clock.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTime.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -1610,6 +1613,9 @@
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Clock.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\DateTime.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -4169,6 +4169,9 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\src\Clock.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTime.cpp">
|
||||
</File>
|
||||
@@ -4278,6 +4281,9 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\include\Poco\Clock.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DateTime.h">
|
||||
</File>
|
||||
|
@@ -5413,6 +5413,10 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\Clock.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTime.cpp"
|
||||
>
|
||||
@@ -5557,6 +5561,10 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Clock.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DateTime.h"
|
||||
>
|
||||
|
@@ -5406,6 +5406,10 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\Clock.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTime.cpp"
|
||||
>
|
||||
@@ -5550,6 +5554,10 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Clock.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DateTime.h"
|
||||
>
|
||||
|
@@ -932,6 +932,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\UUID.cpp" />
|
||||
<ClCompile Include="src\UUIDGenerator.cpp" />
|
||||
<ClCompile Include="src\Clock.cpp" />
|
||||
<ClCompile Include="src\DateTime.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormat.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatter.cpp" />
|
||||
@@ -1230,6 +1231,7 @@
|
||||
<ClInclude Include="include\Poco\SharedMemory_WIN32.h" />
|
||||
<ClInclude Include="include\Poco\UUID.h" />
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h" />
|
||||
<ClInclude Include="include\Poco\Clock.h" />
|
||||
<ClInclude Include="include\Poco\DateTime.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormat.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormatter.h" />
|
||||
|
@@ -774,6 +774,9 @@
|
||||
<ClCompile Include="src\UUIDGenerator.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Clock.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTime.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -1613,6 +1616,9 @@
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Clock.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\DateTime.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -938,6 +938,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\UUID.cpp" />
|
||||
<ClCompile Include="src\UUIDGenerator.cpp" />
|
||||
<ClCompile Include="src\Clock.cpp" />
|
||||
<ClCompile Include="src\DateTime.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormat.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatter.cpp" />
|
||||
@@ -1236,6 +1237,7 @@
|
||||
<ClInclude Include="include\Poco\SharedMemory_WIN32.h" />
|
||||
<ClInclude Include="include\Poco\UUID.h" />
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h" />
|
||||
<ClInclude Include="include\Poco\Clock.h" />
|
||||
<ClInclude Include="include\Poco\DateTime.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormat.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormatter.h" />
|
||||
|
@@ -774,6 +774,9 @@
|
||||
<ClCompile Include="src\UUIDGenerator.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Clock.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTime.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -1613,6 +1616,9 @@
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Clock.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\DateTime.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -938,6 +938,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\UUID.cpp" />
|
||||
<ClCompile Include="src\UUIDGenerator.cpp" />
|
||||
<ClCompile Include="src\Clock.cpp" />
|
||||
<ClCompile Include="src\DateTime.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormat.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatter.cpp" />
|
||||
@@ -1236,6 +1237,7 @@
|
||||
<ClInclude Include="include\Poco\SharedMemory_WIN32.h" />
|
||||
<ClInclude Include="include\Poco\UUID.h" />
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h" />
|
||||
<ClInclude Include="include\Poco\Clock.h" />
|
||||
<ClInclude Include="include\Poco\DateTime.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormat.h" />
|
||||
<ClInclude Include="include\Poco\DateTimeFormatter.h" />
|
||||
|
@@ -774,6 +774,9 @@
|
||||
<ClCompile Include="src\UUIDGenerator.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Clock.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTime.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -1613,6 +1616,9 @@
|
||||
<ClInclude Include="include\Poco\UUIDGenerator.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Clock.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\DateTime.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -5408,6 +5408,10 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\Clock.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTime.cpp"
|
||||
>
|
||||
@@ -5552,6 +5556,10 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Clock.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DateTime.h"
|
||||
>
|
||||
|
@@ -10,7 +10,7 @@ include $(POCO_BASE)/build/rules/global
|
||||
|
||||
objects = ArchiveStrategy Ascii ASCIIEncoding AsyncChannel \
|
||||
Base32Decoder Base32Encoder Base64Decoder Base64Encoder \
|
||||
BinaryReader BinaryWriter Bugcheck ByteOrder Channel Checksum Configurable ConsoleChannel \
|
||||
BinaryReader BinaryWriter Bugcheck ByteOrder Channel Checksum Clock Configurable ConsoleChannel \
|
||||
Condition CountingStream DateTime LocalDateTime DateTimeFormat DateTimeFormatter DateTimeParser \
|
||||
Debugger DeflatingStream DigestEngine DigestStream DirectoryIterator DirectoryWatcher \
|
||||
Environment Event Error EventArgs ErrorHandler Exception FIFOBufferStream FPEnvironment File \
|
||||
|
241
Foundation/include/Poco/Clock.h
Normal file
241
Foundation/include/Poco/Clock.h
Normal file
@@ -0,0 +1,241 @@
|
||||
//
|
||||
// Clock.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Clock.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
// Module: Clock
|
||||
//
|
||||
// Definition of the Clock class.
|
||||
//
|
||||
// Copyright (c) 2013, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Clock_INCLUDED
|
||||
#define Foundation_Clock_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API Clock
|
||||
/// A Clock stores a monotonic* clock value
|
||||
/// with (theoretical) microseconds resolution.
|
||||
/// Clocks can be compared with each other
|
||||
/// and simple arithmetics are supported.
|
||||
///
|
||||
/// [*] Note that Clock values are only monotonic if
|
||||
/// the operating system provides a monotonic clock.
|
||||
/// The monotonic() function can be used to check whether
|
||||
/// the system's clock is monotonic.
|
||||
///
|
||||
/// Monotonic Clock is available on Windows, Linux, OS X
|
||||
/// and on POSIX platforms supporting clock_gettime() with CLOCK_MONOTONIC.
|
||||
///
|
||||
/// Clock values are relative to a system-dependent epoch time
|
||||
/// (usually the system's startup time) and have no relation
|
||||
/// to the time of day.
|
||||
{
|
||||
public:
|
||||
typedef Int64 ClockVal; /// monotonic clock value in microsecond resolution
|
||||
typedef Int64 ClockDiff; /// difference between two clock values in microseconds
|
||||
|
||||
Clock();
|
||||
/// Creates a Clock with the current system clock value.
|
||||
|
||||
Clock(ClockVal tv);
|
||||
/// Creates a Clock from the given clock value.
|
||||
|
||||
Clock(const Clock& other);
|
||||
/// Copy constructor.
|
||||
|
||||
~Clock();
|
||||
/// Destroys the Clock.
|
||||
|
||||
Clock& operator = (const Clock& other);
|
||||
Clock& operator = (ClockVal tv);
|
||||
|
||||
void swap(Clock& clock);
|
||||
/// Swaps the Clock with another one.
|
||||
|
||||
void update();
|
||||
/// Updates the Clock with the current system clock.
|
||||
|
||||
bool operator == (const Clock& ts) const;
|
||||
bool operator != (const Clock& ts) const;
|
||||
bool operator > (const Clock& ts) const;
|
||||
bool operator >= (const Clock& ts) const;
|
||||
bool operator < (const Clock& ts) const;
|
||||
bool operator <= (const Clock& ts) const;
|
||||
|
||||
Clock operator + (ClockDiff d) const;
|
||||
Clock operator - (ClockDiff d) const;
|
||||
ClockDiff operator - (const Clock& ts) const;
|
||||
Clock& operator += (ClockDiff d);
|
||||
Clock& operator -= (ClockDiff d);
|
||||
|
||||
ClockVal microseconds() const;
|
||||
/// Returns the clock value expressed in microseconds
|
||||
/// since the system-specific epoch time (usually system
|
||||
/// startup).
|
||||
|
||||
ClockDiff elapsed() const;
|
||||
/// Returns the time elapsed since the time denoted by
|
||||
/// the Clock instance. Equivalent to Clock() - *this.
|
||||
|
||||
bool isElapsed(ClockDiff interval) const;
|
||||
/// Returns true iff the given interval has passed
|
||||
/// since the time denoted by the Clock instance.
|
||||
|
||||
static ClockVal resolution();
|
||||
/// Returns the resolution in units per second.
|
||||
/// Since the Clock clas has microsecond resolution,
|
||||
/// the returned value is always 1000000.
|
||||
|
||||
static ClockVal accuracy();
|
||||
/// Returns the system's clock accuracy in microseconds.
|
||||
|
||||
static bool monotonic();
|
||||
/// Returns true iff the system's clock is monotonic.
|
||||
|
||||
private:
|
||||
ClockVal _clock;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline bool Clock::operator == (const Clock& ts) const
|
||||
{
|
||||
return _clock == ts._clock;
|
||||
}
|
||||
|
||||
|
||||
inline bool Clock::operator != (const Clock& ts) const
|
||||
{
|
||||
return _clock != ts._clock;
|
||||
}
|
||||
|
||||
|
||||
inline bool Clock::operator > (const Clock& ts) const
|
||||
{
|
||||
return _clock > ts._clock;
|
||||
}
|
||||
|
||||
|
||||
inline bool Clock::operator >= (const Clock& ts) const
|
||||
{
|
||||
return _clock >= ts._clock;
|
||||
}
|
||||
|
||||
|
||||
inline bool Clock::operator < (const Clock& ts) const
|
||||
{
|
||||
return _clock < ts._clock;
|
||||
}
|
||||
|
||||
|
||||
inline bool Clock::operator <= (const Clock& ts) const
|
||||
{
|
||||
return _clock <= ts._clock;
|
||||
}
|
||||
|
||||
|
||||
inline Clock Clock::operator + (Clock::ClockDiff d) const
|
||||
{
|
||||
return Clock(_clock + d);
|
||||
}
|
||||
|
||||
|
||||
inline Clock Clock::operator - (Clock::ClockDiff d) const
|
||||
{
|
||||
return Clock(_clock - d);
|
||||
}
|
||||
|
||||
|
||||
inline Clock::ClockDiff Clock::operator - (const Clock& ts) const
|
||||
{
|
||||
return _clock - ts._clock;
|
||||
}
|
||||
|
||||
|
||||
inline Clock& Clock::operator += (Clock::ClockDiff d)
|
||||
{
|
||||
_clock += d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Clock& Clock::operator -= (Clock::ClockDiff d)
|
||||
{
|
||||
_clock -= d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Clock::ClockVal Clock::microseconds() const
|
||||
{
|
||||
return _clock;
|
||||
}
|
||||
|
||||
|
||||
inline Clock::ClockDiff Clock::elapsed() const
|
||||
{
|
||||
Clock now;
|
||||
return now - *this;
|
||||
}
|
||||
|
||||
|
||||
inline bool Clock::isElapsed(Clock::ClockDiff interval) const
|
||||
{
|
||||
Clock now;
|
||||
Clock::ClockDiff diff = now - *this;
|
||||
return diff >= interval;
|
||||
}
|
||||
|
||||
|
||||
inline Clock::ClockVal Clock::resolution()
|
||||
{
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
|
||||
inline void swap(Clock& s1, Clock& s2)
|
||||
{
|
||||
s1.swap(s2);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Clock_INCLUDED
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Stopwatch.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Stopwatch.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Stopwatch.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#include "Poco/Clock.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -50,11 +50,6 @@ namespace Poco {
|
||||
class Foundation_API Stopwatch
|
||||
/// A simple facility to measure time intervals
|
||||
/// with microsecond resolution.
|
||||
///
|
||||
/// Note that Stopwatch is based on the Timestamp
|
||||
/// class. Therefore, if during a Stopwatch run,
|
||||
/// the system time is changed, the measured time
|
||||
/// will not be correct.
|
||||
{
|
||||
public:
|
||||
Stopwatch();
|
||||
@@ -72,7 +67,7 @@ public:
|
||||
void restart();
|
||||
/// Resets and starts the stopwatch.
|
||||
|
||||
Timestamp::TimeDiff elapsed() const;
|
||||
Clock::ClockDiff elapsed() const;
|
||||
/// Returns the elapsed time in microseconds
|
||||
/// since the stopwatch started.
|
||||
|
||||
@@ -80,15 +75,15 @@ public:
|
||||
/// Returns the number of seconds elapsed
|
||||
/// since the stopwatch started.
|
||||
|
||||
static Timestamp::TimeVal resolution();
|
||||
static Clock::ClockVal resolution();
|
||||
/// Returns the resolution of the stopwatch.
|
||||
|
||||
private:
|
||||
Stopwatch(const Stopwatch&);
|
||||
Stopwatch& operator = (const Stopwatch&);
|
||||
|
||||
Timestamp _start;
|
||||
Timestamp::TimeDiff _elapsed;
|
||||
Clock _start;
|
||||
Clock::ClockDiff _elapsed;
|
||||
bool _running;
|
||||
};
|
||||
|
||||
@@ -110,7 +105,7 @@ inline void Stopwatch::stop()
|
||||
{
|
||||
if (_running)
|
||||
{
|
||||
Timestamp current;
|
||||
Clock current;
|
||||
_elapsed += current - _start;
|
||||
_running = false;
|
||||
}
|
||||
@@ -123,9 +118,9 @@ inline int Stopwatch::elapsedSeconds() const
|
||||
}
|
||||
|
||||
|
||||
inline Timestamp::TimeVal Stopwatch::resolution()
|
||||
inline Clock::ClockVal Stopwatch::resolution()
|
||||
{
|
||||
return Timestamp::resolution();
|
||||
return Clock::resolution();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// TimedNotificationQueue.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/TimedNotificationQueue.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/TimedNotificationQueue.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Notifications
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/Event.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#include "Poco/Clock.h"
|
||||
#include <map>
|
||||
|
||||
|
||||
@@ -87,6 +88,17 @@ public:
|
||||
/// a call like
|
||||
/// notificationQueue.enqueueNotification(new MyNotification, someTime);
|
||||
/// does not result in a memory leak.
|
||||
///
|
||||
/// The Timestamp is converted to an equivalent Clock value.
|
||||
|
||||
void enqueueNotification(Notification::Ptr pNotification, Clock clock);
|
||||
/// Enqueues the given notification by adding it to
|
||||
/// the queue according to the given clock value.
|
||||
/// Lower clock values are inserted before higher ones.
|
||||
/// The queue takes ownership of the notification, thus
|
||||
/// a call like
|
||||
/// notificationQueue.enqueueNotification(new MyNotification, someTime);
|
||||
/// does not result in a memory leak.
|
||||
|
||||
Notification* dequeueNotification();
|
||||
/// Dequeues the next pending notification with a timestamp
|
||||
@@ -105,8 +117,6 @@ public:
|
||||
/// to be enqueued.
|
||||
/// The caller gains ownership of the notification and
|
||||
/// is expected to release it when done with it.
|
||||
/// This method returns 0 (null) if wakeUpWaitingThreads()
|
||||
/// has been called by another thread.
|
||||
///
|
||||
/// It is highly recommended that the result is immediately
|
||||
/// assigned to a Notification::Ptr, to avoid potential
|
||||
@@ -138,9 +148,9 @@ public:
|
||||
/// behavior.
|
||||
|
||||
protected:
|
||||
typedef std::multimap<Timestamp, Notification::Ptr> NfQueue;
|
||||
typedef std::multimap<Clock, Notification::Ptr> NfQueue;
|
||||
Notification::Ptr dequeueOne(NfQueue::iterator& it);
|
||||
bool wait(Timestamp::TimeDiff interval);
|
||||
bool wait(Clock::ClockDiff interval);
|
||||
|
||||
private:
|
||||
NfQueue _nfQueue;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Timer.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Timer.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Timer.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/Event.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#include "Poco/Clock.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -169,7 +169,7 @@ private:
|
||||
Event _done;
|
||||
long _skipped;
|
||||
AbstractTimerCallback* _pCallback;
|
||||
Timestamp _nextInvocation;
|
||||
Clock _nextInvocation;
|
||||
mutable FastMutex _mutex;
|
||||
|
||||
Timer(const Timer&);
|
||||
|
234
Foundation/src/Clock.cpp
Normal file
234
Foundation/src/Clock.cpp
Normal file
@@ -0,0 +1,234 @@
|
||||
//
|
||||
// Clock.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/src/Clock.cpp#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
// Module: Clock
|
||||
//
|
||||
// Copyright (c) 2013, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Clock.h"
|
||||
#include "Poco/Exception.h"
|
||||
#if defined(__MACH__)
|
||||
#include <mach/mach.h>
|
||||
#include <mach/clock.h>
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include <time.h>
|
||||
#elif defined(POCO_VXWORKS)
|
||||
#include <timers.h>
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/UnWindows.h"
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
Clock::Clock()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Clock::Clock(ClockVal tv)
|
||||
{
|
||||
_clock = tv;
|
||||
}
|
||||
|
||||
|
||||
Clock::Clock(const Clock& other)
|
||||
{
|
||||
_clock = other._clock;
|
||||
}
|
||||
|
||||
|
||||
Clock::~Clock()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Clock& Clock::operator = (const Clock& other)
|
||||
{
|
||||
_clock = other._clock;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Clock& Clock::operator = (ClockVal tv)
|
||||
{
|
||||
_clock = tv;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Clock::swap(Clock& timestamp)
|
||||
{
|
||||
std::swap(_clock, timestamp._clock);
|
||||
}
|
||||
|
||||
|
||||
void Clock::update()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
||||
LARGE_INTEGER perfCounter;
|
||||
LARGE_INTEGER perfFreq;
|
||||
if (QueryPerformanceCounter(&perfCounter) && QueryPerformanceFrequency(&perfFreq))
|
||||
{
|
||||
_clock = perfCounter.QuadPart*resolution()/perfFreq.QuadPart;
|
||||
}
|
||||
else throw Poco::SystemException("cannot get system clock");
|
||||
|
||||
#elif defined(__MACH__)
|
||||
|
||||
clock_serv_t cs;
|
||||
mach_timespec_t ts;
|
||||
|
||||
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
|
||||
clock_get_time(cs, &ts);
|
||||
mach_port_deallocate(mach_task_self(), cs);
|
||||
|
||||
_clock = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
|
||||
|
||||
#elif defined(POCO_VXWORKS)
|
||||
|
||||
struct timespec ts;
|
||||
#if defined(CLOCK_MONOTONIC) // should be in VxWorks 6.x
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts))
|
||||
throw SystemException("cannot get system clock");
|
||||
#else
|
||||
if (clock_gettime(CLOCK_REALTIME, &ts))
|
||||
throw SystemException("cannot get system clock");
|
||||
#endif
|
||||
_clock = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
|
||||
|
||||
#elif defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts))
|
||||
throw SystemException("cannot get system clock");
|
||||
_clock = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
|
||||
|
||||
#else
|
||||
|
||||
Poco::Timestamp now;
|
||||
_clock = now.epochMicroseconds();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Clock::ClockVal Clock::accuracy()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
||||
LARGE_INTEGER perfFreq;
|
||||
if (QueryPerformanceFrequency(&perfFreq) && perfFreq.QuadPart > 0)
|
||||
{
|
||||
ClockVal acc = resolution()/perfFreq.QuadPart;
|
||||
return acc > 0 ? acc : 1;
|
||||
}
|
||||
else throw Poco::SystemException("cannot get system clock accuracy");
|
||||
|
||||
#elif defined(__MACH__)
|
||||
|
||||
clock_serv_t cs;
|
||||
int nanosecs;
|
||||
mach_msg_type_number_t n = 1;
|
||||
|
||||
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
|
||||
clock_get_attributes(cs, CLOCK_GET_TIME_RES, (clock_attr_t)&nanosecs, &n);
|
||||
mach_port_deallocate(mach_task_self(), cs);
|
||||
|
||||
ClockVal acc = nanosecs/1000;
|
||||
return acc > 0 ? acc : 1;
|
||||
|
||||
#elif defined(POCO_VXWORKS)
|
||||
|
||||
struct timespec ts;
|
||||
#if defined(CLOCK_MONOTONIC) // should be in VxWorks 6.x
|
||||
if (clock_getres(CLOCK_MONOTONIC, &ts))
|
||||
throw SystemException("cannot get system clock");
|
||||
#else
|
||||
if (clock_getres(CLOCK_REALTIME, &ts))
|
||||
throw SystemException("cannot get system clock");
|
||||
#endif
|
||||
ClockVal acc = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
|
||||
return acc > 0 ? acc : 1;
|
||||
|
||||
#elif defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
|
||||
struct timespec ts;
|
||||
if (clock_getres(CLOCK_MONOTONIC, &ts))
|
||||
throw SystemException("cannot get system clock");
|
||||
|
||||
ClockVal acc = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
|
||||
return acc > 0 ? acc : 1;
|
||||
|
||||
#else
|
||||
|
||||
return 1000;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool Clock::monotonic()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
||||
return true;
|
||||
|
||||
#elif defined(__MACH__)
|
||||
|
||||
return true;
|
||||
|
||||
#elif defined(POCO_VXWORKS)
|
||||
|
||||
#if defined(CLOCK_MONOTONIC) // should be in VxWorks 6.x
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#elif defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
|
||||
return true;
|
||||
|
||||
#else
|
||||
|
||||
return false;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Stopwatch.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/src/Stopwatch.cpp#1 $
|
||||
// $Id: //poco/1.4/Foundation/src/Stopwatch.cpp#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@@ -50,11 +50,11 @@ Stopwatch::~Stopwatch()
|
||||
}
|
||||
|
||||
|
||||
Timestamp::TimeDiff Stopwatch::elapsed() const
|
||||
Clock::ClockDiff Stopwatch::elapsed() const
|
||||
{
|
||||
if (_running)
|
||||
{
|
||||
Timestamp current;
|
||||
Clock current;
|
||||
return _elapsed + (current - _start);
|
||||
}
|
||||
else
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// TimedNotificationQueue.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/src/TimedNotificationQueue.cpp#1 $
|
||||
// $Id: //poco/1.4/Foundation/src/TimedNotificationQueue.cpp#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Notifications
|
||||
@@ -57,8 +57,23 @@ void TimedNotificationQueue::enqueueNotification(Notification::Ptr pNotification
|
||||
{
|
||||
poco_check_ptr (pNotification);
|
||||
|
||||
Timestamp tsNow;
|
||||
Clock clock;
|
||||
Timestamp::TimeDiff diff = timestamp - tsNow;
|
||||
clock += diff;
|
||||
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
_nfQueue.insert(NfQueue::value_type(timestamp, pNotification));
|
||||
_nfQueue.insert(NfQueue::value_type(clock, pNotification));
|
||||
_nfAvailable.set();
|
||||
}
|
||||
|
||||
|
||||
void TimedNotificationQueue::enqueueNotification(Notification::Ptr pNotification, Clock clock)
|
||||
{
|
||||
poco_check_ptr (pNotification);
|
||||
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
_nfQueue.insert(NfQueue::value_type(clock, pNotification));
|
||||
_nfAvailable.set();
|
||||
}
|
||||
|
||||
@@ -70,7 +85,7 @@ Notification* TimedNotificationQueue::dequeueNotification()
|
||||
NfQueue::iterator it = _nfQueue.begin();
|
||||
if (it != _nfQueue.end())
|
||||
{
|
||||
Timestamp::TimeDiff sleep = -it->first.elapsed();
|
||||
Clock::ClockDiff sleep = -it->first.elapsed();
|
||||
if (sleep <= 0)
|
||||
{
|
||||
Notification::Ptr pNf = it->second;
|
||||
@@ -91,7 +106,7 @@ Notification* TimedNotificationQueue::waitDequeueNotification()
|
||||
if (it != _nfQueue.end())
|
||||
{
|
||||
_mutex.unlock();
|
||||
Timestamp::TimeDiff sleep = -it->first.elapsed();
|
||||
Clock::ClockDiff sleep = -it->first.elapsed();
|
||||
if (sleep <= 0)
|
||||
{
|
||||
return dequeueOne(it).duplicate();
|
||||
@@ -120,13 +135,13 @@ Notification* TimedNotificationQueue::waitDequeueNotification(long milliseconds)
|
||||
if (it != _nfQueue.end())
|
||||
{
|
||||
_mutex.unlock();
|
||||
Poco::Timestamp now;
|
||||
Timestamp::TimeDiff sleep = it->first - now;
|
||||
Clock now;
|
||||
Clock::ClockDiff sleep = it->first - now;
|
||||
if (sleep <= 0)
|
||||
{
|
||||
return dequeueOne(it).duplicate();
|
||||
}
|
||||
else if (sleep <= 1000*Timestamp::TimeDiff(milliseconds))
|
||||
else if (sleep <= 1000*Clock::ClockDiff(milliseconds))
|
||||
{
|
||||
if (!wait(sleep))
|
||||
{
|
||||
@@ -145,7 +160,7 @@ Notification* TimedNotificationQueue::waitDequeueNotification(long milliseconds)
|
||||
}
|
||||
if (milliseconds > 0)
|
||||
{
|
||||
Poco::Timestamp now;
|
||||
Clock now;
|
||||
_nfAvailable.tryWait(milliseconds);
|
||||
milliseconds -= static_cast<long>((now.elapsed() + 999)/1000);
|
||||
}
|
||||
@@ -155,13 +170,13 @@ Notification* TimedNotificationQueue::waitDequeueNotification(long milliseconds)
|
||||
}
|
||||
|
||||
|
||||
bool TimedNotificationQueue::wait(Timestamp::TimeDiff interval)
|
||||
bool TimedNotificationQueue::wait(Clock::ClockDiff interval)
|
||||
{
|
||||
const Timestamp::TimeDiff MAX_SLEEP = 8*60*60*Timestamp::TimeDiff(1000000); // sleep at most 8 hours at a time
|
||||
const Clock::ClockDiff MAX_SLEEP = 8*60*60*Clock::ClockDiff(1000000); // sleep at most 8 hours at a time
|
||||
while (interval > 0)
|
||||
{
|
||||
Timestamp now;
|
||||
Timestamp::TimeDiff sleep = interval <= MAX_SLEEP ? interval : MAX_SLEEP;
|
||||
Clock now;
|
||||
Clock::ClockDiff sleep = interval <= MAX_SLEEP ? interval : MAX_SLEEP;
|
||||
if (_nfAvailable.tryWait(static_cast<long>((sleep + 999)/1000)))
|
||||
return true;
|
||||
interval -= now.elapsed();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Timer.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/src/Timer.cpp#1 $
|
||||
// $Id: //poco/1.4/Foundation/src/Timer.cpp#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -79,8 +79,8 @@ void Timer::start(const AbstractTimerCallback& method, ThreadPool& threadPool)
|
||||
|
||||
void Timer::start(const AbstractTimerCallback& method, Thread::Priority priority, ThreadPool& threadPool)
|
||||
{
|
||||
Timestamp nextInvocation;
|
||||
nextInvocation += static_cast<Timestamp::TimeVal>(_startInterval)*1000;
|
||||
Clock nextInvocation;
|
||||
nextInvocation += static_cast<Clock::ClockVal>(_startInterval)*1000;
|
||||
|
||||
poco_assert (!_pCallback);
|
||||
|
||||
@@ -162,7 +162,7 @@ void Timer::setPeriodicInterval(long milliseconds)
|
||||
|
||||
void Timer::run()
|
||||
{
|
||||
Poco::Timestamp now;
|
||||
Poco::Clock now;
|
||||
long interval(0);
|
||||
do
|
||||
{
|
||||
@@ -178,7 +178,7 @@ void Timer::run()
|
||||
sleep = 0;
|
||||
break;
|
||||
}
|
||||
_nextInvocation += static_cast<Timestamp::TimeVal>(interval)*1000;
|
||||
_nextInvocation += static_cast<Clock::ClockVal>(interval)*1000;
|
||||
++_skipped;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ void Timer::run()
|
||||
}
|
||||
interval = _periodicInterval;
|
||||
}
|
||||
_nextInvocation += static_cast<Timestamp::TimeVal>(interval)*1000;
|
||||
_nextInvocation += static_cast<Clock::ClockVal>(interval)*1000;
|
||||
_skipped = 0;
|
||||
}
|
||||
while (interval > 0);
|
||||
|
@@ -11,7 +11,7 @@ include $(POCO_BASE)/build/rules/global
|
||||
objects = ActiveMethodTest ActivityTest ActiveDispatcherTest \
|
||||
AutoPtrTest ArrayTest SharedPtrTest AutoReleasePoolTest \
|
||||
Base32Test Base64Test BinaryReaderWriterTest LineEndingConverterTest \
|
||||
ByteOrderTest ChannelTest ClassLoaderTest CoreTest CoreTestSuite \
|
||||
ByteOrderTest ChannelTest ClassLoaderTest ClockTest CoreTest CoreTestSuite \
|
||||
CountingStreamTest CryptTestSuite DateTimeFormatterTest \
|
||||
DateTimeParserTest DateTimeTest LocalDateTimeTest DateTimeTestSuite DigestStreamTest \
|
||||
Driver DynamicFactoryTest FPETest FileChannelTest FileTest GlobTest FilesystemTestSuite \
|
||||
|
@@ -1382,6 +1382,10 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.cpp"
|
||||
>
|
||||
@@ -1422,6 +1426,10 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.h"
|
||||
>
|
||||
|
@@ -388,6 +388,7 @@
|
||||
<ClCompile Include="src\UUIDGeneratorTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp" />
|
||||
<ClCompile Include="src\ClockTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeParserTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeTest.cpp" />
|
||||
@@ -524,6 +525,7 @@
|
||||
<ClInclude Include="src\UUIDGeneratorTest.h" />
|
||||
<ClInclude Include="src\UUIDTest.h" />
|
||||
<ClInclude Include="src\UUIDTestSuite.h" />
|
||||
<ClInclude Include="src\ClockTest.h" />
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h" />
|
||||
<ClInclude Include="src\DateTimeParserTest.h" />
|
||||
<ClInclude Include="src\DateTimeTest.h" />
|
||||
|
@@ -417,6 +417,9 @@
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ClockTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -821,6 +824,9 @@
|
||||
<ClInclude Include="src\UUIDTestSuite.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ClockTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -393,6 +393,7 @@
|
||||
<ClCompile Include="src\UUIDGeneratorTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp" />
|
||||
<ClCompile Include="src\ClockTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeParserTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeTest.cpp" />
|
||||
@@ -529,6 +530,7 @@
|
||||
<ClInclude Include="src\UUIDGeneratorTest.h" />
|
||||
<ClInclude Include="src\UUIDTest.h" />
|
||||
<ClInclude Include="src\UUIDTestSuite.h" />
|
||||
<ClInclude Include="src\ClockTest.h" />
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h" />
|
||||
<ClInclude Include="src\DateTimeParserTest.h" />
|
||||
<ClInclude Include="src\DateTimeTest.h" />
|
||||
|
@@ -426,6 +426,9 @@
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ClockTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -830,6 +833,9 @@
|
||||
<ClInclude Include="src\UUIDTestSuite.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ClockTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -410,6 +410,7 @@
|
||||
<ClCompile Include="src\UUIDGeneratorTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp" />
|
||||
<ClCompile Include="src\ClockTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeParserTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeTest.cpp" />
|
||||
@@ -545,6 +546,7 @@
|
||||
<ClInclude Include="src\UUIDGeneratorTest.h" />
|
||||
<ClInclude Include="src\UUIDTest.h" />
|
||||
<ClInclude Include="src\UUIDTestSuite.h" />
|
||||
<ClInclude Include="src\ClockTest.h" />
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h" />
|
||||
<ClInclude Include="src\DateTimeParserTest.h" />
|
||||
<ClInclude Include="src\DateTimeTest.h" />
|
||||
|
@@ -426,6 +426,9 @@
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ClockTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -830,6 +833,9 @@
|
||||
<ClInclude Include="src\UUIDTestSuite.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ClockTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -1021,6 +1021,9 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.cpp">
|
||||
</File>
|
||||
@@ -1052,6 +1055,9 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.h">
|
||||
</File>
|
||||
|
@@ -1351,6 +1351,10 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.cpp"
|
||||
>
|
||||
@@ -1391,6 +1395,10 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.h"
|
||||
>
|
||||
|
@@ -1337,6 +1337,10 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.cpp"
|
||||
>
|
||||
@@ -1377,6 +1381,10 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.h"
|
||||
>
|
||||
|
@@ -387,6 +387,7 @@
|
||||
<ClCompile Include="src\UUIDGeneratorTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp" />
|
||||
<ClCompile Include="src\ClockTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeParserTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeTest.cpp" />
|
||||
@@ -524,6 +525,7 @@
|
||||
<ClInclude Include="src\UUIDGeneratorTest.h" />
|
||||
<ClInclude Include="src\UUIDTest.h" />
|
||||
<ClInclude Include="src\UUIDTestSuite.h" />
|
||||
<ClInclude Include="src\ClockTest.h" />
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h" />
|
||||
<ClInclude Include="src\DateTimeParserTest.h" />
|
||||
<ClInclude Include="src\DateTimeTest.h" />
|
||||
|
@@ -426,6 +426,9 @@
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ClockTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -833,6 +836,9 @@
|
||||
<ClInclude Include="src\UUIDTestSuite.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ClockTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -393,6 +393,7 @@
|
||||
<ClCompile Include="src\UUIDGeneratorTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp" />
|
||||
<ClCompile Include="src\ClockTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeParserTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeTest.cpp" />
|
||||
@@ -530,6 +531,7 @@
|
||||
<ClInclude Include="src\UUIDGeneratorTest.h" />
|
||||
<ClInclude Include="src\UUIDTest.h" />
|
||||
<ClInclude Include="src\UUIDTestSuite.h" />
|
||||
<ClInclude Include="src\ClockTest.h" />
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h" />
|
||||
<ClInclude Include="src\DateTimeParserTest.h" />
|
||||
<ClInclude Include="src\DateTimeTest.h" />
|
||||
|
@@ -426,6 +426,9 @@
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ClockTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -833,6 +836,9 @@
|
||||
<ClInclude Include="src\UUIDTestSuite.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ClockTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -394,6 +394,7 @@
|
||||
<ClCompile Include="src\UUIDGeneratorTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTest.cpp" />
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp" />
|
||||
<ClCompile Include="src\ClockTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeParserTest.cpp" />
|
||||
<ClCompile Include="src\DateTimeTest.cpp" />
|
||||
@@ -530,6 +531,7 @@
|
||||
<ClInclude Include="src\UUIDGeneratorTest.h" />
|
||||
<ClInclude Include="src\UUIDTest.h" />
|
||||
<ClInclude Include="src\UUIDTestSuite.h" />
|
||||
<ClInclude Include="src\ClockTest.h" />
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h" />
|
||||
<ClInclude Include="src\DateTimeParserTest.h" />
|
||||
<ClInclude Include="src\DateTimeTest.h" />
|
||||
|
@@ -426,6 +426,9 @@
|
||||
<ClCompile Include="src\UUIDTestSuite.cpp">
|
||||
<Filter>UUID\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ClockTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DateTimeFormatterTest.cpp">
|
||||
<Filter>DateTime\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -833,6 +836,9 @@
|
||||
<ClInclude Include="src\UUIDTestSuite.h">
|
||||
<Filter>UUID\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ClockTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\DateTimeFormatterTest.h">
|
||||
<Filter>DateTime\Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@@ -1331,6 +1331,10 @@
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.cpp"
|
||||
>
|
||||
@@ -1371,6 +1375,10 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\ClockTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DateTimeFormatterTest.h"
|
||||
>
|
||||
|
107
Foundation/testsuite/src/ClockTest.cpp
Normal file
107
Foundation/testsuite/src/ClockTest.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// ClockTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/testsuite/src/ClockTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2013, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "ClockTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Clock.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using Poco::Clock;
|
||||
using Poco::Thread;
|
||||
|
||||
|
||||
ClockTest::ClockTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ClockTest::~ClockTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ClockTest::testClock()
|
||||
{
|
||||
Clock t1;
|
||||
Thread::sleep(200);
|
||||
Clock t2;
|
||||
Clock t3 = t2;
|
||||
assert (t1 != t2);
|
||||
assert (!(t1 == t2));
|
||||
assert (t2 > t1);
|
||||
assert (t2 >= t1);
|
||||
assert (!(t1 > t2));
|
||||
assert (!(t1 >= t2));
|
||||
assert (t2 == t3);
|
||||
assert (!(t2 != t3));
|
||||
assert (t2 >= t3);
|
||||
assert (t2 <= t3);
|
||||
Clock::ClockDiff d = (t2 - t1);
|
||||
assert (d >= 180000 && d <= 300000);
|
||||
|
||||
Clock::ClockDiff acc = Clock::accuracy();
|
||||
assert (acc > 0 && acc < Clock::resolution());
|
||||
std::cout << "Clock accuracy: " << acc << std::endl;
|
||||
|
||||
t1.swap(t2);
|
||||
assert (t1 > t2);
|
||||
t2.swap(t1);
|
||||
|
||||
Clock now;
|
||||
Thread::sleep(201);
|
||||
assert (now.elapsed() >= 200000);
|
||||
assert (now.isElapsed(200000));
|
||||
assert (!now.isElapsed(2000000));
|
||||
}
|
||||
|
||||
|
||||
void ClockTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ClockTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* ClockTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ClockTest");
|
||||
|
||||
CppUnit_addTest(pSuite, ClockTest, testClock);
|
||||
|
||||
return pSuite;
|
||||
}
|
60
Foundation/testsuite/src/ClockTest.h
Normal file
60
Foundation/testsuite/src/ClockTest.h
Normal file
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// ClockTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/testsuite/src/ClockTest.h#1 $
|
||||
//
|
||||
// Definition of the ClockTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef ClockTest_INCLUDED
|
||||
#define ClockTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class ClockTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ClockTest(const std::string& name);
|
||||
~ClockTest();
|
||||
|
||||
void testClock();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // ClockTest_INCLUDED
|
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "DateTimeTestSuite.h"
|
||||
#include "TimestampTest.h"
|
||||
#include "ClockTest.h"
|
||||
#include "TimespanTest.h"
|
||||
#include "TimezoneTest.h"
|
||||
#include "DateTimeTest.h"
|
||||
@@ -45,6 +46,7 @@ CppUnit::Test* DateTimeTestSuite::suite()
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DateTimeTestSuite");
|
||||
|
||||
pSuite->addTest(TimestampTest::suite());
|
||||
pSuite->addTest(ClockTest::suite());
|
||||
pSuite->addTest(TimespanTest::suite());
|
||||
pSuite->addTest(TimezoneTest::suite());
|
||||
pSuite->addTest(DateTimeTest::suite());
|
||||
|
Reference in New Issue
Block a user