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;
59 r = yaz_gettimeofday(&abstime);
62 abstime.tv_sec += 1; /* wait 1 second */
64 r = yaz_cond_wait(c, p, &abstime);
70 yaz_mutex_destroy(&p);
74 static void *my_handler(void *arg)
76 int *mydata = (int*) arg;
81 static void tst_create_thread(void)
87 t[0] = yaz_thread_create(my_handler, &mydata);
89 t[1] = yaz_thread_create(my_handler, &mydata);
93 yaz_thread_join(&t[0], &return_data);
95 YAZ_CHECK(return_data == &mydata);
98 yaz_thread_join(&t[1], &return_data);
100 YAZ_CHECK(return_data == &mydata);
102 YAZ_CHECK_EQ(mydata, 44);
105 int main (int argc, char **argv)
107 YAZ_CHECK_INIT(argc, argv);
118 * c-file-style: "Stroustrup"
119 * indent-tabs-mode: nil
121 * vim: shiftwidth=4 tabstop=8 expandtab