1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 Index Data
3 * See the file LICENSE for details.
10 #include <yaz/thread_create.h>
20 #include <yaz/gettimeofday.h>
22 static void tst_mutex(void)
30 yaz_mutex_destroy(&p);
35 yaz_mutex_set_name(p, YLOG_LOG, "mymutex");
38 yaz_mutex_destroy(&p);
41 yaz_mutex_destroy(&p); /* OK to "destroy" NULL handle */
44 static void tst_cond(void)
48 struct timeval abstime;
61 r = yaz_gettimeofday(&abstime);
64 abstime.tv_sec += 1; /* wait 1 second */
66 r = yaz_cond_wait(c, p, &abstime);
71 yaz_mutex_destroy(&p);
75 static void *my_handler(void *arg)
77 int *mydata = (int*) arg;
82 static void tst_create_thread(void)
88 t[0] = yaz_thread_create(my_handler, &mydata);
90 t[1] = yaz_thread_create(my_handler, &mydata);
94 yaz_thread_join(&t[0], &return_data);
96 YAZ_CHECK(return_data == &mydata);
99 yaz_thread_join(&t[1], &return_data);
101 YAZ_CHECK(return_data == &mydata);
103 YAZ_CHECK_EQ(mydata, 44);
106 int main (int argc, char **argv)
108 YAZ_CHECK_INIT(argc, argv);
119 * c-file-style: "Stroustrup"
120 * indent-tabs-mode: nil
122 * vim: shiftwidth=4 tabstop=8 expandtab