Commit 49338b29 authored by Juho Snellman's avatar Juho Snellman

Rename Timestamp to Tick

parent 85dacab1
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <cstdio> #include <cstdio>
#include <list> #include <list>
typedef uint64_t Timestamp; typedef uint64_t Tick;
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;
} }
Timestamp scheduled_at() { return scheduled_at_; } Tick scheduled_at() { return scheduled_at_; }
void set_scheduled_at(Timestamp ts) { scheduled_at_ = ts; } void set_scheduled_at(Tick 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;
Timestamp scheduled_at_; Tick 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(Timestamp delta) { void advance(Tick 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, Timestamp delta) { void schedule(TimerEvent<CBType>* event, Tick 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, Timestamp absolute) { void schedule_absolute(TimerEvent<CBType>* event, Tick absolute) {
Timestamp delta; Tick 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);
} }
Timestamp now_; Tick 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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment