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:
Axel Dörfler 2006-11-21 23:20:41 +00:00
parent 1da73a7b9b
commit 390422241e
1 changed files with 7 additions and 3 deletions

View File

@ -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,17 +309,19 @@ 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
if (sTimerTimeout > timer->due)
release_sem(sTimerWaitSem); release_sem(sTimerWaitSem);
} }
}
status_t 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)