diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-09-08 03:17:05 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-09-08 03:17:05 +0000 |
commit | 2be79fd8f7a9e6d68d0c1a6a8fb936761137e416 (patch) | |
tree | c116bdaea64a7a386e01eff738ef870f5cae8ac6 /libpthread/linuxthreads/manager.c | |
parent | 11740630bb377e0c943c645aee2c19c7a07be200 (diff) |
import the helper function pthread_for_each_thread from glibc
Diffstat (limited to 'libpthread/linuxthreads/manager.c')
-rw-r--r-- | libpthread/linuxthreads/manager.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/libpthread/linuxthreads/manager.c b/libpthread/linuxthreads/manager.c index 204344aef..585789e22 100644 --- a/libpthread/linuxthreads/manager.c +++ b/libpthread/linuxthreads/manager.c @@ -107,13 +107,18 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, int report_events, td_thr_events_t *event_maskp); static void pthread_handle_free(pthread_t th_id); -static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode); +static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode) + __attribute__ ((noreturn)); static void pthread_reap_children(void); static void pthread_kill_all_threads(int sig, int main_thread_also); +static void pthread_for_each_thread(void *arg, + void (*fn)(void *, pthread_descr)); /* The server thread managing requests for thread creation and termination */ -int __pthread_manager(void *arg) +int +__attribute__ ((noreturn)) +__pthread_manager(void *arg) { int reqfd = (int) (long int) arg; #ifdef USE_SELECT @@ -248,6 +253,11 @@ int __pthread_manager(void *arg) /* This is just a prod to get the manager to reap some threads right away, avoiding a potential delay at shutdown. */ break; + case REQ_FOR_EACH_THREAD: + pthread_for_each_thread(request.req_args.for_each.arg, + request.req_args.for_each.fn); + restart(request.req_thread); + break; } } } @@ -839,6 +849,20 @@ static void pthread_kill_all_threads(int sig, int main_thread_also) } } +static void pthread_for_each_thread(void *arg, + void (*fn)(void *, pthread_descr)) +{ + pthread_descr th; + + for (th = __pthread_main_thread->p_nextlive; + th != __pthread_main_thread; + th = th->p_nextlive) { + fn(arg, th); + } + + fn(arg, __pthread_main_thread); +} + /* Process-wide exit() */ static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode) |