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
Hide 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 @@
...
@@ -12,7 +12,7 @@
#include <cstdio>
#include <cstdio>
#include <list>
#include <list>
typedef
uint64_t
Ti
mestamp
;
typedef
uint64_t
Ti
ck
;
template
<
typename
CBType
>
template
<
typename
CBType
>
class
TimerWheelSlot
;
class
TimerWheelSlot
;
...
@@ -66,14 +66,14 @@ public:
...
@@ -66,14 +66,14 @@ public:
return
slot_
!=
NULL
;
return
slot_
!=
NULL
;
}
}
Ti
mestamp
scheduled_at
()
{
return
scheduled_at_
;
}
Ti
ck
scheduled_at
()
{
return
scheduled_at_
;
}
void
set_scheduled_at
(
Ti
mestamp
ts
)
{
scheduled_at_
=
ts
;
}
void
set_scheduled_at
(
Ti
ck
ts
)
{
scheduled_at_
=
ts
;
}
private:
private:
TimerEvent
(
const
TimerEvent
&
other
)
=
delete
;
TimerEvent
(
const
TimerEvent
&
other
)
=
delete
;
TimerEvent
&
operator
=
(
const
TimerEvent
&
other
)
=
delete
;
TimerEvent
&
operator
=
(
const
TimerEvent
&
other
)
=
delete
;
Ti
mestamp
scheduled_at_
;
Ti
ck
scheduled_at_
;
CBType
callback_
;
CBType
callback_
;
// The slot this event is currently in (NULL if not currently scheduled).
// The slot this event is currently in (NULL if not currently scheduled).
TimerWheelSlot
<
CBType
>*
slot_
=
NULL
;
TimerWheelSlot
<
CBType
>*
slot_
=
NULL
;
...
@@ -128,7 +128,7 @@ public:
...
@@ -128,7 +128,7 @@ public:
down_
(
NULL
)
{
down_
(
NULL
)
{
}
}
void
advance
(
Ti
mestamp
delta
)
{
void
advance
(
Ti
ck
delta
)
{
while
(
delta
--
)
{
while
(
delta
--
)
{
now_
++
;
now_
++
;
size_t
slot_index
=
now_
&
MASK
;
size_t
slot_index
=
now_
&
MASK
;
...
@@ -148,7 +148,7 @@ public:
...
@@ -148,7 +148,7 @@ public:
}
}
}
}
void
schedule
(
TimerEvent
<
CBType
>*
event
,
Ti
mestamp
delta
)
{
void
schedule
(
TimerEvent
<
CBType
>*
event
,
Ti
ck
delta
)
{
if
(
!
down_
)
{
if
(
!
down_
)
{
event
->
set_scheduled_at
(
now_
+
delta
);
event
->
set_scheduled_at
(
now_
+
delta
);
}
}
...
@@ -174,8 +174,8 @@ private:
...
@@ -174,8 +174,8 @@ private:
}
}
}
}
void
schedule_absolute
(
TimerEvent
<
CBType
>*
event
,
Ti
mestamp
absolute
)
{
void
schedule_absolute
(
TimerEvent
<
CBType
>*
event
,
Ti
ck
absolute
)
{
Ti
mestamp
delta
;
Ti
ck
delta
;
delta
=
absolute
-
now_
;
delta
=
absolute
-
now_
;
assert
(
absolute
>=
now_
);
assert
(
absolute
>=
now_
);
assert
(
delta
<
NUM_SLOTS
);
assert
(
delta
<
NUM_SLOTS
);
...
@@ -191,7 +191,7 @@ private:
...
@@ -191,7 +191,7 @@ private:
schedule
(
event
,
delta
);
schedule
(
event
,
delta
);
}
}
Ti
mestamp
now_
;
Ti
ck
now_
;
static
const
int
WIDTH_BITS
=
8
;
static
const
int
WIDTH_BITS
=
8
;
static
const
int
NUM_SLOTS
=
1
<<
WIDTH_BITS
;
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