}
/* Add new read thread. */
-void
+struct thread *
funcname_thread_add_read_write (int dir, struct thread_master *m,
int (*func) (struct thread *), void *arg, int fd, struct thread **t_ptr,
debugargdef)
if (t_ptr && *t_ptr) // thread is already scheduled; don't reschedule
{
pthread_mutex_unlock (&m->mtx);
- return;
+ return NULL;
}
#if defined (HAVE_POLL_CALL)
}
}
pthread_mutex_unlock (&m->mtx);
+
+ return thread;
}
-static void
+static struct thread *
funcname_thread_add_timer_timeval (struct thread_master *m,
int (*func) (struct thread *), int type, void *arg,
struct timeval *time_relative, struct thread **t_ptr, debugargdef)
if (t_ptr && *t_ptr) // thread is already scheduled; don't reschedule
{
pthread_mutex_unlock (&m->mtx);
- return;
+ return NULL;
}
queue = ((type == THREAD_TIMER) ? m->timer : m->background);
pthread_mutex_unlock (&thread->mtx);
}
pthread_mutex_unlock (&m->mtx);
+
+ return thread;
}
/* Add timer event thread. */
-void
+struct thread *
funcname_thread_add_timer (struct thread_master *m,
int (*func) (struct thread *), void *arg, long timer,
struct thread **t_ptr, debugargdef)
}
/* Add timer event thread with "millisecond" resolution */
-void
+struct thread *
funcname_thread_add_timer_msec (struct thread_master *m,
int (*func) (struct thread *), void *arg, long timer,
struct thread **t_ptr, debugargdef)
trel.tv_sec = timer / 1000;
trel.tv_usec = 1000*(timer % 1000);
- funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, &trel,
- t_ptr, debugargpass);
+ return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, &trel,
+ t_ptr, debugargpass);
}
/* Add timer event thread with "millisecond" resolution */
-void
+struct thread *
funcname_thread_add_timer_tv (struct thread_master *m,
int (*func) (struct thread *), void *arg, struct timeval *tv,
struct thread **t_ptr, debugargdef)
{
- funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, tv, t_ptr,
- debugargpass);
+ return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, tv,
+ t_ptr, debugargpass);
}
/* Add a background thread, with an optional millisec delay */
-void
+struct thread *
funcname_thread_add_background (struct thread_master *m,
int (*func) (struct thread *), void *arg, long delay,
struct thread **t_ptr, debugargdef)
trel.tv_usec = 0;
}
- funcname_thread_add_timer_timeval (m, func, THREAD_BACKGROUND, arg, &trel,
- t_ptr, debugargpass);
+ return funcname_thread_add_timer_timeval (m, func, THREAD_BACKGROUND, arg, &trel,
+ t_ptr, debugargpass);
}
/* Add simple event thread. */
-void
+struct thread *
funcname_thread_add_event (struct thread_master *m,
int (*func) (struct thread *), void *arg, int val,
struct thread **t_ptr, debugargdef)
if (t_ptr && *t_ptr) // thread is already scheduled; don't reschedule
{
pthread_mutex_unlock (&m->mtx);
- return;
+ return NULL;
}
thread = thread_get (m, THREAD_EVENT, func, arg, debugargpass);
}
}
pthread_mutex_unlock (&m->mtx);
+
+ return thread;
}
static void
extern void thread_master_free (struct thread_master *);
extern void thread_master_free_unused(struct thread_master *);
-extern void funcname_thread_add_read_write (int dir, struct thread_master *,
+extern struct thread * funcname_thread_add_read_write (int dir, struct thread_master *,
int (*)(struct thread *), void *, int, struct thread **, debugargdef);
-extern void funcname_thread_add_timer (struct thread_master *,
+extern struct thread * funcname_thread_add_timer (struct thread_master *,
int (*)(struct thread *), void *, long, struct thread **, debugargdef);
-extern void funcname_thread_add_timer_msec (struct thread_master *,
+extern struct thread * funcname_thread_add_timer_msec (struct thread_master *,
int (*)(struct thread *), void *, long, struct thread **, debugargdef);
-extern void funcname_thread_add_timer_tv (struct thread_master *,
+extern struct thread * funcname_thread_add_timer_tv (struct thread_master *,
int (*)(struct thread *), void *, struct timeval *, struct thread **, debugargdef);
-extern void funcname_thread_add_event (struct thread_master *,
+extern struct thread * funcname_thread_add_event (struct thread_master *,
int (*)(struct thread *), void *, int, struct thread **, debugargdef);
-extern void funcname_thread_add_background (struct thread_master *,
+extern struct thread * funcname_thread_add_background (struct thread_master *,
int (*)(struct thread *), void *, long, struct thread **, debugargdef);
extern void funcname_thread_execute (struct thread_master *,