OSDN Git Service

Merge branch 'master' of git.sourceforge.jp:/gitroot/eos/base
[eos/hostdependX86LINUX64.git] / include / eosPThread.h
1 /*
2 # eosPThread.h : $Revision$  
3 # $Date$ 
4 # Created by $Author$
5 # Usage : eosPThread.h 
6 # Attention
7 #   $Loccker$
8 #       $State$ 
9 #
10 */
11 /* $Log$ */
12 #ifndef EOS_PTHREAD_H
13 #define EOS_PTHRED_H 
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <pthread.h>
18 #include <errno.h>
19
20 /* constant begin */
21
22 extern int __eosPThread__;
23 extern int __eosPThreadNum__;
24
25 /* constant end */
26
27 /* struct begin */
28
29 typedef enum eosPThreadStatus {
30         eosPThreadStatusWaiting = 0,
31         eosPThreadStatusRunning = 1
32 } eosPThreadStatus;
33
34 typedef struct eosPThread {
35         pthread_t*                      th;         /* [max] thread */
36         eosPThreadStatus*       status;     /* [max] thread status */
37         long*                           id;         /* [max] thread ID indicated by count */
38
39         int                             max;            /* maximum thread number working simultaneously. */ 
40         long                            count;          /* count of created threads */   
41         long                            latest;     /* working thread ID which started latest */
42         long                            oldest;     /* working thread ID which started oldest */
43 } eosPThread;
44
45 /* struct end */
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 /* prototype begin */
52 extern void eosPThreadInit   (eosPThread* t, int max, int mode);
53 extern int  eosPThreadCreateOnWaitingThread (eosPThread* t, void* (*start_routine)(void *), void * arg, int mode);
54 extern int  eosPThreadCreate (eosPThread* t, int i, void* (*start_routine)(void *), void * arg, int mode);
55 extern void eosPThreadJoin   (eosPThread* t, int i, int mode);
56 extern void eosPThreadJoinAll(eosPThread* t, int mode);
57
58 extern void eosPThreadMutexInit(eosPThread* t);
59 extern void eosPThreadMutexLock(eosPThread* t);
60 extern void eosPThreadMutexUnlock(eosPThread* t);
61
62 /* prototype end */
63
64 #ifdef __cplusplus
65 };
66 #endif
67
68 #endif  /* EOS_PTHREAD_H */