Small optimization of the timer mechanism: the timeout is no longer updated
if not really necessary; ie. you can now add timers without an extra performance hit if it's not really required. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19354 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1da73a7b9b
commit
390422241e
|
@ -21,6 +21,7 @@ static struct list sTimers;
|
||||||
static benaphore sTimerLock;
|
static benaphore sTimerLock;
|
||||||
static sem_id sTimerWaitSem;
|
static sem_id sTimerWaitSem;
|
||||||
static thread_id sTimerThread;
|
static thread_id sTimerThread;
|
||||||
|
static bigtime_t sTimerTimeout;
|
||||||
|
|
||||||
|
|
||||||
uint16
|
uint16
|
||||||
|
@ -256,6 +257,7 @@ timer_thread(void * /*data*/)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sTimerTimeout = timeout;
|
||||||
benaphore_unlock(&sTimerLock);
|
benaphore_unlock(&sTimerLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,10 +309,11 @@ set_timer(net_timer *timer, bigtime_t delay)
|
||||||
// add this timer
|
// add this timer
|
||||||
timer->due = system_time() + delay;
|
timer->due = system_time() + delay;
|
||||||
list_add_item(&sTimers, timer);
|
list_add_item(&sTimers, timer);
|
||||||
}
|
|
||||||
|
|
||||||
// notify timer about the change
|
// notify timer about the change if necessary
|
||||||
release_sem(sTimerWaitSem);
|
if (sTimerTimeout > timer->due)
|
||||||
|
release_sem(sTimerWaitSem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -318,6 +321,7 @@ status_t
|
||||||
init_timers(void)
|
init_timers(void)
|
||||||
{
|
{
|
||||||
list_init(&sTimers);
|
list_init(&sTimers);
|
||||||
|
sTimerTimeout = B_INFINITE_TIMEOUT;
|
||||||
|
|
||||||
status_t status = benaphore_init(&sTimerLock, "net timer");
|
status_t status = benaphore_init(&sTimerLock, "net timer");
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
|
|
Loading…
Reference in New Issue