Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
Ratas
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Ratas
Commits
49338b29
Commit
49338b29
authored
Jul 18, 2016
by
Juho Snellman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Timestamp to Tick
parent
85dacab1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
src/timer-wheel.h
src/timer-wheel.h
+9
-9
No files found.
src/timer-wheel.h
View file @
49338b29
...
...
@@ -12,7 +12,7 @@
#include <cstdio>
#include <list>
typedef
uint64_t
Ti
mestamp
;
typedef
uint64_t
Ti
ck
;
template
<
typename
CBType
>
class
TimerWheelSlot
;
...
...
@@ -66,14 +66,14 @@ public:
return
slot_
!=
NULL
;
}
Ti
mestamp
scheduled_at
()
{
return
scheduled_at_
;
}
void
set_scheduled_at
(
Ti
mestamp
ts
)
{
scheduled_at_
=
ts
;
}
Ti
ck
scheduled_at
()
{
return
scheduled_at_
;
}
void
set_scheduled_at
(
Ti
ck
ts
)
{
scheduled_at_
=
ts
;
}
private:
TimerEvent
(
const
TimerEvent
&
other
)
=
delete
;
TimerEvent
&
operator
=
(
const
TimerEvent
&
other
)
=
delete
;
Ti
mestamp
scheduled_at_
;
Ti
ck
scheduled_at_
;
CBType
callback_
;
// The slot this event is currently in (NULL if not currently scheduled).
TimerWheelSlot
<
CBType
>*
slot_
=
NULL
;
...
...
@@ -128,7 +128,7 @@ public:
down_
(
NULL
)
{
}
void
advance
(
Ti
mestamp
delta
)
{
void
advance
(
Ti
ck
delta
)
{
while
(
delta
--
)
{
now_
++
;
size_t
slot_index
=
now_
&
MASK
;
...
...
@@ -148,7 +148,7 @@ public:
}
}
void
schedule
(
TimerEvent
<
CBType
>*
event
,
Ti
mestamp
delta
)
{
void
schedule
(
TimerEvent
<
CBType
>*
event
,
Ti
ck
delta
)
{
if
(
!
down_
)
{
event
->
set_scheduled_at
(
now_
+
delta
);
}
...
...
@@ -174,8 +174,8 @@ private:
}
}
void
schedule_absolute
(
TimerEvent
<
CBType
>*
event
,
Ti
mestamp
absolute
)
{
Ti
mestamp
delta
;
void
schedule_absolute
(
TimerEvent
<
CBType
>*
event
,
Ti
ck
absolute
)
{
Ti
ck
delta
;
delta
=
absolute
-
now_
;
assert
(
absolute
>=
now_
);
assert
(
delta
<
NUM_SLOTS
);
...
...
@@ -191,7 +191,7 @@ private:
schedule
(
event
,
delta
);
}
Ti
mestamp
now_
;
Ti
ck
now_
;
static
const
int
WIDTH_BITS
=
8
;
static
const
int
NUM_SLOTS
=
1
<<
WIDTH_BITS
;
...
...
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