Back to index

courier  0.68.2
nopthread.h
Go to the documentation of this file.
00001 #ifndef       nopthread_h
00002 #define       nopthread_h
00003 
00004 /*
00005 ** Copyright 2000 Double Precision, Inc.  See COPYING for
00006 ** distribution information.
00007 */
00008 
00009 
00010 #if    HAVE_CONFIG_H
00011 #include      "config.h"
00012 #endif
00013 
00014 struct cthreadinfo {
00015        void (*workfunc)(void *);
00016        void (*cleanupfunc)(void *);
00017        char *metadata_buf;
00018        } ;
00019 
00020 struct cthreadinfo *cthread_init(
00021        unsigned,            /* Number of threads */
00022        unsigned,            /* Size of per-thread metadata */
00023        void (*)(void *),    /* The work function */
00024        void (*)(void *));   /* The cleanup function */
00025 
00026 void cthread_wait(struct cthreadinfo *);
00027 
00028 #define       cthread_go(cit, gofunc, arg)       \
00029        ( (*gofunc)(cit->metadata_buf, arg),      \
00030               (*cit->workfunc)(cit->metadata_buf), \
00031               (*cit->cleanupfunc)(cit->metadata_buf), 0)
00032 
00033 struct cthreadlock *cthread_lockcreate(void);
00034 void cthread_lockdestroy(struct cthreadlock *);
00035 int cthread_lock(struct cthreadlock *, int (*)(void *), void *);
00036 
00037 extern struct cthreadlock cthread_dummy;
00038 
00039 #define       cthread_lockcreate() ( &cthread_dummy )
00040 #define       cthread_lockdestroy(p)
00041 #define       cthread_lock(p,func,arg)    ( (*func)(arg))
00042 
00043 #endif