Commit fab654db authored by Juho Snellman's avatar Juho Snellman

Documentation improvements

parent 4e51f48d
...@@ -83,7 +83,7 @@ for execution (with =schedule()= or =schedule_in_range()=), and will ...@@ -83,7 +83,7 @@ for execution (with =schedule()= or =schedule_in_range()=), and will
eventually be executed once the time advances far enough with the eventually be executed once the time advances far enough with the
=advance()= method. =advance()= method.
***** =TimerWheel::advance(Tick delta, int level = 0)= ***** =TimerWheel::advance(Tick delta, size_t max_execute = ..., int level = 0)=
Advance the TimerWheel by the specified number of ticks (=delta=), and execute Advance the TimerWheel by the specified number of ticks (=delta=), and execute
any events scheduled for execution at or before that time. The any events scheduled for execution at or before that time. The
number of events executed can be restricted using the =max_execute= number of events executed can be restricted using the =max_execute=
...@@ -100,28 +100,30 @@ and the excess events will be processed on a subsequent call. ...@@ -100,28 +100,30 @@ and the excess events will be processed on a subsequent call.
Delta should be non-0. The only exception is if the previous Delta should be non-0. The only exception is if the previous
call to =advance()= returned false. call to =advance()= returned false.
=advance()= should not be called from an event callback.
The =level= parameter is used to trigger timer advances on different The =level= parameter is used to trigger timer advances on different
levels of the hierarchy. It will generally not be useful to pass in levels of the hierarchy. It will generally not be useful to pass in
any value other than the default 0. any value other than the default 0.
***** =schedule(TimerEventInterface* event, Tick delta)= ***** =TimerWheel::schedule(TimerEventInterface* event, Tick delta)=
Schedule the event to be executed =delta= ticks from the current time. Schedule the event to be executed =delta= ticks from the current time.
The delta must be non-0. The delta must be non-0.
***** =schedule_in_range(TimerEventInterface* event, Tick start, Tick end)= ***** =TimerWheel::schedule_in_range(TimerEventInterface* event, Tick start, Tick end)=
Schedule the event to happen at some time between start and end Schedule the event to happen at some time between start and end
ticks from the current time. The actual time will be determined ticks from the current time. The actual time will be determined
by the =TimerWheel= to minimize rescheduling and promotion overhead. by the =TimerWheel= to minimize rescheduling and promotion overhead.
Both =start= and =end= must be non-0, and =end= must be greater than Both =start= and =end= must be non-0, and =end= must be greater than
=start=. =start=.
***** =now()= ***** =TimerWheel::now()=
Return the current tick value. Note that if the time increases Return the current tick value. Note that if the time increases
by multiple ticks during a single call to advance(), during the by multiple ticks during a single call to advance(), during the
execution of the event callback now() will return the tick that execution of the event callback now() will return the tick that
the event was scheduled to run on. the event was scheduled to run on.
***** =ticks_to_next_event(const Tick& max = ..., int level = 0)= ***** =TimerWheel::ticks_to_next_event(Tick max = ..., int level = 0)=
Return the number of ticks remaining until the next event will get Return the number of ticks remaining until the next event will get
executed. If the max parameter is passed, that will be the maximum executed. If the max parameter is passed, that will be the maximum
tick value that gets returned. The max parameter's value will also tick value that gets returned. The max parameter's value will also
......
...@@ -239,6 +239,8 @@ public: ...@@ -239,6 +239,8 @@ public:
// //
// Delta should be non-0. The only exception is if the previous // Delta should be non-0. The only exception is if the previous
// call to advance() returned false. // call to advance() returned false.
//
// advance() should not be called from an event callback.
bool advance(Tick delta, bool advance(Tick delta,
size_t max_execute=std::numeric_limits<size_t>::max(), size_t max_execute=std::numeric_limits<size_t>::max(),
int level = 0); int level = 0);
...@@ -268,7 +270,7 @@ public: ...@@ -268,7 +270,7 @@ public:
// //
// Will return 0 if the wheel still has unprocessed events from the // Will return 0 if the wheel still has unprocessed events from the
// previous call to advance(). // previous call to advance().
Tick ticks_to_next_event(const Tick& max = std::numeric_limits<Tick>::max(), Tick ticks_to_next_event(Tick max = std::numeric_limits<Tick>::max(),
int level = 0); int level = 0);
private: private:
...@@ -467,7 +469,7 @@ void TimerWheel::schedule_in_range(TimerEventInterface* event, ...@@ -467,7 +469,7 @@ void TimerWheel::schedule_in_range(TimerEventInterface* event,
schedule(event, delta); schedule(event, delta);
} }
Tick TimerWheel::ticks_to_next_event(const Tick& max, int level) { Tick TimerWheel::ticks_to_next_event(Tick max, int level) {
if (ticks_pending_) { if (ticks_pending_) {
return 0; return 0;
} }
......
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