Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
98ade8b6
Commit
98ade8b6
authored
Sep 25, 2016
by
Kenton Varda
Committed by
Kenton Varda
Apr 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Clock interface to time.h, for reading the current wall time / date.
parent
956ca5fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
time.c++
c++/src/kj/time.c++
+9
-0
time.h
c++/src/kj/time.h
+10
-0
No files found.
c++/src/kj/time.c++
View file @
98ade8b6
...
...
@@ -30,6 +30,15 @@ kj::Exception Timer::makeTimeoutException() {
return
KJ_EXCEPTION
(
OVERLOADED
,
"operation timed out"
);
}
Clock
&
nullClock
()
{
class
NullClock
final
:
public
Clock
{
public
:
Date
now
()
override
{
return
UNIX_EPOCH
;
}
};
static
NullClock
NULL_CLOCK
;
return
NULL_CLOCK
;
}
struct
TimerImpl
::
Impl
{
struct
TimerBefore
{
bool
operator
()(
TimerPromiseAdapter
*
lhs
,
TimerPromiseAdapter
*
rhs
);
...
...
c++/src/kj/time.h
View file @
98ade8b6
...
...
@@ -61,6 +61,16 @@ using Date = Absolute<Duration, _::DateLabel>;
constexpr
Date
UNIX_EPOCH
=
origin
<
Date
>
();
// The `Date` representing Jan 1, 1970 00:00:00 UTC.
class
Clock
{
// Interface to read the current date and time.
public
:
virtual
Date
now
()
=
0
;
};
Clock
&
nullClock
();
// A clock which always returns UNIX_EPOCH as the current time. Useful when you don't care about
// time.
class
Timer
{
// Interface to time and timer functionality.
//
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment