* Added TRACE macro to see what timers are set/cancelled.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30166 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-04-15 10:21:58 +00:00
parent b4a57bf88b
commit a96e91db3b
+20 -7
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -20,6 +20,14 @@
#include "stack_private.h" #include "stack_private.h"
//#define TRACE_UTILITY
#ifdef TRACE_UTILITY
# define TRACE(x...) dprintf(x)
#else
# define TRACE(x...) ;
#endif
// internal Fifo class which doesn't maintain it's own lock // internal Fifo class which doesn't maintain it's own lock
// TODO: do we need this one for anything? // TODO: do we need this one for anything?
class Fifo { class Fifo {
@@ -489,19 +497,21 @@ init_timer(net_timer* timer, net_timer_func hook, void* data)
} }
/*! /*! Sets or cancels a timer. When the \a delay is below zero, an eventually
Sets or cancels a timer. When the \a delay is below zero, an eventually running running timer is canceled, if not, it is scheduled to be executed after the
timer is canceled, if not, it is scheduled to be executed after the specified specified \a delay.
\a delay.
You need to have initialized the timer before calling this function. You need to have initialized the timer before calling this function.
In case you need to change a running timer, you have to cancel it first, before
making any changes. In case you need to change a running timer, you have to cancel it first,
before making any changes.
*/ */
void void
set_timer(net_timer* timer, bigtime_t delay) set_timer(net_timer* timer, bigtime_t delay)
{ {
MutexLocker locker(sTimerLock); MutexLocker locker(sTimerLock);
TRACE("set_timer %p, hook %p, data %p\n", timer, timer->hook, timer->data);
if (timer->due > 0 && delay < 0) { if (timer->due > 0 && delay < 0) {
// this timer is scheduled, cancel it // this timer is scheduled, cancel it
list_remove_item(&sTimers, timer); list_remove_item(&sTimers, timer);
@@ -527,6 +537,9 @@ cancel_timer(struct net_timer* timer)
{ {
MutexLocker locker(sTimerLock); MutexLocker locker(sTimerLock);
TRACE("cancel_timer %p, hook %p, data %p\n", timer, timer->hook,
timer->data);
if (timer->due <= 0) if (timer->due <= 0)
return false; return false;