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
|
#ifndef nopthread_h
#define nopthread_h
/*
** Copyright 2000 Double Precision, Inc. See COPYING for
** distribution information.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
struct cthreadinfo {
void (*workfunc)(void *);
void (*cleanupfunc)(void *);
char *metadata_buf;
} ;
struct cthreadinfo *cthread_init(
unsigned, /* Number of threads */
unsigned, /* Size of per-thread metadata */
void (*)(void *), /* The work function */
void (*)(void *)); /* The cleanup function */
void cthread_wait(struct cthreadinfo *);
#define cthread_go(cit, gofunc, arg) \
( (*gofunc)(cit->metadata_buf, arg), \
(*cit->workfunc)(cit->metadata_buf), \
(*cit->cleanupfunc)(cit->metadata_buf), 0)
struct cthreadlock *cthread_lockcreate(void);
void cthread_lockdestroy(struct cthreadlock *);
int cthread_lock(struct cthreadlock *, int (*)(void *), void *);
extern struct cthreadlock cthread_dummy;
#define cthread_lockcreate() ( &cthread_dummy )
#define cthread_lockdestroy(p)
#define cthread_lock(p,func,arg) ( (*func)(arg))
#endif
|