1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/* This file is part of the YAZ toolkit.
* Copyright (C) Index Data
* See the file LICENSE for details.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include <assert.h>
#include <stdlib.h>
#include <yaz/log.h>
#include <yaz/options.h>
#if YAZ_POSIX_THREADS
#include <pthread.h>
static void *t_loop2(void *vp)
{
int i, sz = 10;
for (i = 0; i<sz; i++)
{
#if 0
fprintf(stderr, "pr %d\n", i);
#else
yaz_log(YLOG_LOG, "pr %d", i);
#endif
}
return 0;
}
static void t_test(void)
{
pthread_t tids[4];
pthread_create(tids+0, 0, t_loop2, 0);
pthread_create(tids+1, 0, t_loop2, 0);
pthread_create(tids+2, 0, t_loop2, 0);
pthread_create(tids+3, 0, t_loop2, 0);
pthread_join(tids[0], 0);
pthread_join(tids[1], 0);
pthread_join(tids[2], 0);
pthread_join(tids[3], 0);
exit(0);
}
#else
static void t_test(void)
{
}
#endif
int main(int argc, char **argv)
{
char *arg;
int ret;
/* t_test is only invoked if a non-option arg is given .. */
while ((ret = options("v:l:", argv, argc, &arg)) != -2)
{
switch (ret)
{
case 'v':
yaz_log_init_level (yaz_log_mask_str(arg));
break;
case 'l':
yaz_log_init_file(arg);
break;
case 0:
t_test();
break;
default:
exit(1);
}
}
return 0;
}
/*
* Local variables:
* c-basic-offset: 4
* c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
*/
|