mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:48:13 +00:00
Kernel: Expose timers via a TimerId type
The public consumers of the timer API shouldn't need to know the how timer id's are tracked internally. Expose a typedef instead to allow the internal implementation to be protected from potential churn in the future. It's also just good API design.
This commit is contained in:
parent
13c122b8b2
commit
eeb5318c25
3 changed files with 10 additions and 8 deletions
|
@ -34,8 +34,10 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
typedef u64 TimerId;
|
||||
|
||||
struct Timer {
|
||||
u64 id;
|
||||
TimerId id;
|
||||
u64 expires;
|
||||
Function<void()> callback;
|
||||
bool operator<(const Timer& rhs) const
|
||||
|
@ -56,9 +58,9 @@ class TimerQueue {
|
|||
public:
|
||||
static TimerQueue& the();
|
||||
|
||||
u64 add_timer(NonnullOwnPtr<Timer>&&);
|
||||
u64 add_timer(timeval& timeout, Function<void()>&& callback);
|
||||
bool cancel_timer(u64 id);
|
||||
TimerId add_timer(NonnullOwnPtr<Timer>&&);
|
||||
TimerId add_timer(timeval& timeout, Function<void()>&& callback);
|
||||
bool cancel_timer(TimerId id);
|
||||
void fire();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue