mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
Kernel: Remove an allocation when blocking a thread
When blocking a thread with a timeout we would previously allocate a Timer object. This removes the allocation for that Timer object.
This commit is contained in:
parent
96b75af5d1
commit
7557f2db90
5 changed files with 42 additions and 23 deletions
|
@ -24,12 +24,14 @@ class Timer : public RefCounted<Timer>
|
|||
friend class InlineLinkedListNode<Timer>;
|
||||
|
||||
public:
|
||||
Timer(clockid_t clock_id, Time expires, Function<void()>&& callback)
|
||||
: m_clock_id(clock_id)
|
||||
, m_expires(expires)
|
||||
, m_callback(move(callback))
|
||||
void setup(clockid_t clock_id, Time expires, Function<void()>&& callback)
|
||||
{
|
||||
VERIFY(!is_queued());
|
||||
m_clock_id = clock_id;
|
||||
m_expires = expires;
|
||||
m_callback = move(callback);
|
||||
}
|
||||
|
||||
~Timer()
|
||||
{
|
||||
VERIFY(!is_queued());
|
||||
|
@ -72,7 +74,7 @@ public:
|
|||
static TimerQueue& the();
|
||||
|
||||
TimerId add_timer(NonnullRefPtr<Timer>&&);
|
||||
RefPtr<Timer> add_timer_without_id(clockid_t, const Time&, Function<void()>&&);
|
||||
bool add_timer_without_id(NonnullRefPtr<Timer>, clockid_t, const Time&, Function<void()>&&);
|
||||
TimerId add_timer(clockid_t, const Time& timeout, Function<void()>&& callback);
|
||||
bool cancel_timer(TimerId id);
|
||||
bool cancel_timer(Timer&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue