1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 Index Data
3 * See the file LICENSE for details.
7 * \file thread_create.c
8 * \brief Implements thread creation wrappers
20 #include <yaz/xmalloc.h>
22 #include <yaz/thread_create.h>
42 yaz_thread_t yaz_thread_create(void *(*start_routine)(void *p), void *arg)
44 yaz_thread_t t = xmalloc(sizeof(*t));
46 int r = pthread_create(&t->id, 0, start_routine, arg);
53 t->return_data = start_routine(arg);
58 void yaz_thread_join(yaz_thread_t *tp, void **value_ptr)
62 #ifdef YAZ_POSIX_THREADS
63 pthread_join((*tp)->id, value_ptr);
66 *value_ptr = (*tp)->return_data;
73 void yaz_thread_detach(yaz_thread_t *tp)
77 #ifdef YAZ_POSIX_THREADS
78 pthread_detach((*tp)->id);
88 * c-file-style: "Stroustrup"
89 * indent-tabs-mode: nil
91 * vim: shiftwidth=4 tabstop=8 expandtab