Commit 499ef29d authored by Pekka Pessi's avatar Pekka Pessi
Browse files

su: using type su_timer_queue_t (defaults to su_timer_t *)

darcs-hash:20070704091652-65a35-67ea7ece5d1900e919716e4825e7491c3069580a.gz
parent 5a0de7cb
......@@ -341,6 +341,12 @@ typedef void (*su_timer_f)(su_root_magic_t *magic,
su_timer_t *t,
su_timer_arg_t *arg);
#ifndef SU_TIMER_QUEUE_T
#define SU_TIMER_QUEUE_T su_timer_t *
#endif
typedef SU_TIMER_QUEUE_T su_timer_queue_t;
/* ---------------------------------------------------------------------- */
/* Tasks */
......@@ -487,7 +493,7 @@ SOFIAPUBFUN int su_timer_reset(su_timer_t *);
SOFIAPUBFUN su_root_t *su_timer_root(su_timer_t const *);
SOFIAPUBFUN int su_timer_expire(su_timer_t ** const,
SOFIAPUBFUN int su_timer_expire(su_timer_queue_t * const,
su_duration_t *tout,
su_time_t now);
......@@ -505,7 +511,7 @@ SOFIAPUBFUN int su_task_cmp(su_task_r const, su_task_r const);
SOFIAPUBFUN int su_task_is_running(su_task_r const);
SOFIAPUBFUN su_root_t *su_task_root(su_task_r const self);
SOFIAPUBFUN su_timer_t **su_task_timers(su_task_r const self);
SOFIAPUBFUN su_timer_queue_t *su_task_timers(su_task_r const self);
SOFIAPUBFUN int su_task_execute(su_task_r const task,
int (*function)(void *), void *arg,
......
......@@ -477,7 +477,7 @@ int su_base_port_remove_prepoll(su_port_t *self,
* Timers
*/
su_timer_t **su_base_port_timers(su_port_t *self)
su_timer_queue_t *su_base_port_timers(su_port_t *self)
{
return &self->sup_timers;
}
......
......@@ -123,7 +123,7 @@ typedef struct su_port_vtable {
int (*su_port_remove_prepoll)(su_port_t *port,
su_root_t *root);
su_timer_t **(*su_port_timers)(su_port_t *port);
su_timer_queue_t *(*su_port_timers)(su_port_t *port);
int (*su_port_multishot)(su_port_t *port, int multishot);
......@@ -443,7 +443,7 @@ typedef struct su_base_port_s {
su_msg_t *sup_head, **sup_tail;
/* Timer list */
su_timer_t *sup_timers;
su_timer_queue_t sup_timers;
unsigned sup_running; /**< In su_root_run() loop? */
} su_base_port_t;
......
......@@ -313,7 +313,7 @@ int su_task_detach(su_task_r self)
* @return A timer list of the task. If there are no timers, it returns
* NULL.
*/
su_timer_t **su_task_timers(su_task_r const task)
su_timer_queue_t *su_task_timers(su_task_r const task)
{
return task ? su_port_timers(task->sut_port) : NULL;
}
......
......@@ -183,8 +183,8 @@ enum sut_running {
RBTREE_PROTOS(su_inline, timers, su_timer_t);
su_inline int timers_append(su_timer_t **, su_timer_t *);
su_inline void timers_remove(su_timer_t **, su_timer_t *);
su_inline int timers_append(su_timer_queue_t *, su_timer_t *);
su_inline void timers_remove(su_timer_queue_t *, su_timer_t *);
su_inline su_timer_t *timers_succ(su_timer_t const *);
su_inline su_timer_t *timers_prec(su_timer_t const *);
su_inline su_timer_t *timers_first(su_timer_t const *);
......@@ -200,7 +200,7 @@ RBTREE_BODIES(su_inline, timers, su_timer_t,
* @retval 0 when successful (always)
*/
su_inline int
su_timer_set0(su_timer_t **timers,
su_timer_set0(su_timer_queue_t *timers,
su_timer_t *t,
su_timer_f wakeup,
su_wakeup_arg_t *arg,
......@@ -222,7 +222,7 @@ su_timer_set0(su_timer_t **timers,
* @retval 0 when successful (always)
*/
su_inline int
su_timer_reset0(su_timer_t **timers,
su_timer_reset0(su_timer_queue_t *timers,
su_timer_t *t)
{
if (SU_TIMER_IS_SET(t))
......@@ -243,11 +243,11 @@ su_timer_reset0(su_timer_t **timers,
* @retval NULL upon an error
*/
static
su_timer_t **su_timer_tree(su_timer_t const *t,
int use_sut_duration,
char const *caller)
su_timer_queue_t *su_timer_tree(su_timer_t const *t,
int use_sut_duration,
char const *caller)
{
su_timer_t **timers;
su_timer_queue_t *timers;
if (t == NULL) {
SU_DEBUG_1(("%s(%p): %s\n", caller, (void *)t,
......@@ -287,11 +287,10 @@ su_timer_t *su_timer_create(su_task_r const task, su_duration_t msec)
assert(msec >= 0);
if (su_task_cmp(task, su_task_null))
retval = su_zalloc(NULL, sizeof(*retval));
else
retval = NULL;
if (!su_task_cmp(task, su_task_null))
return NULL;
retval = su_zalloc(NULL, sizeof(*retval));
if (retval) {
su_task_copy(retval->sut_task, task);
retval->sut_duration = msec;
......@@ -309,7 +308,7 @@ su_timer_t *su_timer_create(su_task_r const task, su_duration_t msec)
void su_timer_destroy(su_timer_t *t)
{
if (t) {
su_timer_t **timers = su_task_timers(t->sut_task);
su_timer_queue_t *timers = su_task_timers(t->sut_task);
if (timers)
su_timer_reset0(timers, t);
su_task_deinit(t->sut_task);
......@@ -333,7 +332,7 @@ int su_timer_set_interval(su_timer_t *t,
su_timer_arg_t *arg,
su_duration_t interval)
{
su_timer_t **timers = su_timer_tree(t, 0, "su_timer_set_interval");
su_timer_queue_t *timers = su_timer_tree(t, 0, "su_timer_set_interval");
if (t == NULL)
return -1;
......@@ -357,7 +356,7 @@ int su_timer_set(su_timer_t *t,
su_timer_f wakeup,
su_timer_arg_t *arg)
{
su_timer_t **timers = su_timer_tree(t, 1, "su_timer_set");
su_timer_queue_t *timers = su_timer_tree(t, 1, "su_timer_set");
if (timers == NULL)
return -1;
......@@ -381,7 +380,7 @@ int su_timer_set_at(su_timer_t *t,
su_wakeup_arg_t *arg,
su_time_t when)
{
su_timer_t **timers = su_timer_tree(t, 0, "su_timer_set_at");
su_timer_queue_t *timers = su_timer_tree(t, 0, "su_timer_set_at");
if (timers == NULL)
return -1;
......@@ -411,7 +410,7 @@ int su_timer_run(su_timer_t *t,
su_timer_f wakeup,
su_timer_arg_t *arg)
{
su_timer_t **timers = su_timer_tree(t, 1, "su_timer_run");
su_timer_queue_t *timers = su_timer_tree(t, 1, "su_timer_run");
su_time_t now;
if (timers == NULL)
......@@ -444,7 +443,7 @@ int su_timer_set_for_ever(su_timer_t *t,
su_timer_f wakeup,
su_timer_arg_t *arg)
{
su_timer_t **timers = su_timer_tree(t, 1, "su_timer_set_for_ever");
su_timer_queue_t *timers = su_timer_tree(t, 1, "su_timer_set_for_ever");
su_time_t now;
if (timers == NULL)
......@@ -467,7 +466,7 @@ int su_timer_set_for_ever(su_timer_t *t,
*/
int su_timer_reset(su_timer_t *t)
{
su_timer_t **timers = su_timer_tree(t, 0, "su_timer_reset");
su_timer_queue_t *timers = su_timer_tree(t, 0, "su_timer_reset");
if (timers == NULL)
return -1;
......@@ -488,7 +487,7 @@ int su_timer_reset(su_timer_t *t)
* @return
* The number of expired timers.
*/
int su_timer_expire(su_timer_t ** const timers,
int su_timer_expire(su_timer_queue_t * const timers,
su_duration_t *timeout,
su_time_t now)
{
......@@ -572,7 +571,7 @@ su_duration_t su_timer_next_expires(su_timer_t const * t, su_time_t now)
*
* @return Number of timers reset.
*/
int su_timer_reset_all(su_timer_t **timers, su_task_r task)
int su_timer_reset_all(su_timer_queue_t *timers, su_task_r task)
{
su_timer_t *t, *t_next;
int n = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment