Task #1152
closedtime structs
100%
Description
Define time::Duration
and time::Point
types; implement time::now
.
time::Duration
should be convertible to and from nanoseconds.
time::Point
represents a time point in monotonic clock, and doesn't need to relate with UTC time.
These types should support addition, subtraction, and comparison operators.
- Point + Duration => Point
- Point - Point => Duration
- Duration + Duration => Duration
- Duration - Duration => Duration
- Comparisons should take two operands of same type
time::now()
uses monotonic clock on every platform that supports it, otherwise fallback to wall clock.
Updated by Junxiao Shi almost 11 years ago
- Due date deleted (
01/25/2014) - Start date deleted (
01/25/2014)
Updated by Junxiao Shi almost 11 years ago
- Description updated (diff)
- Category set to Core
Updated by Junxiao Shi over 10 years ago
This task should be moved to ndn-cpp-dev, because Task #1290 stage 1 imports time structs and Scheduler from the library.
Updated by Alex Afanasyev over 10 years ago
- Project changed from NFD to ndn-cxx
- Category deleted (
Core) - Target version deleted (
v0.1)
Updated by Jerald Paul Abraham over 10 years ago
- % Done changed from 0 to 30
As there is specific mention of a nanosecond time granularity requirement for ndn::Point and ndn::Duration, I am using the considering two options which are not presently employed in the ndn-cpp-dev library:
- std::chrono::high_resolution_clock (C++ v11 Feature) This offers the smallest available tick in the implementation but is not necessarily platform invariant
- Boost.Chrono (Boost Third Party Library) The advantage is boost takes care of the platform invariant aspect and also has library implemented for most required arithmetic operations
An underlying hardware inability will cause the usage of the next available resolution of time (although it would be externalized as nanoseconds).
Also not sure if we really need nanosecond resolution. Even for the timing wheel implementation, if we are to offer millisecond unit timers, then microsecond granularity is good enough. In that case boost::posix_time would be enough as it has routines for upto microsecond resolution and this would be more aligned to what ndn-cpp-dev uses currently.
Updated by Jerald Paul Abraham over 10 years ago
- Status changed from New to In Progress
Updated by Junxiao Shi over 10 years ago
ndn-cpp-dev is targeting C++03, which does not have std::chrono
.
I’m not sure the targeting Boost version. If it’s above 1.47, this task is done in 0.2 hours:
#ifdef BOOST_HAS_CLOCK_STEADY
#define CLOCK boost::chrono::steady_clock
#else
#define CLOCK boost::chrono::system_clock
#endif
typedef CLOCK::duration Duration;
typedef CLOCK::time_point Point;
inline Point now() { return CLOCK::now(); }
If Boost.Chrono isn’t available, you have to deal with everything with platform-dependent APIs, and this would be a 6 hour task.
Updated by Jerald Paul Abraham over 10 years ago
- Status changed from In Progress to Code review
- % Done changed from 30 to 100
The ndn-cpp-dev Library already has most of this implemented.
All requested requirements of the task have been ensured to be present.
I added the following:
1.New Typedefs:
Microseconds
MicrosecondsSince1970
Nanoseconds
NanosecondsSince1970
2.Add the following operator support for ndn::time::Point and ndn::time::Duration:
==
!=
>=
<=
>
<
<<
3.Added unit tests for all of the above.
Updated by Alex Afanasyev over 10 years ago
- Assignee changed from Jerald Paul Abraham to Alex Afanasyev
Updated by Junxiao Shi over 10 years ago
- Priority changed from Normal to High
Bump priority because two other tasks are blocked on this.
Updated by Alex Afanasyev over 10 years ago
- Status changed from Code review to Closed