cmn-clib(CommonLibraryForC)
C言語共通ライブラリ
 全て データ構造 ファイル 関数 変数 型定義 列挙型 列挙値 マクロ定義
CmnThread.h
[詳解]
1 
10 #ifndef CMNCLIB_CMN_THREAD_H_
11 #define CMNCLIB_CMN_THREAD_H_
12 
13 #include "cmnclib/Common.h"
14 
15 #if IS_PRATFORM_WINDOWS()
16  #include <windows.h>
17  #include <process.h>
18 #else
19  #include <pthread.h>
20 #endif
21 
23 typedef struct tag_CmnThreadMutex {
24 #if IS_PRATFORM_WINDOWS()
25  HANDLE mutexId;
26 #else
27  pthread_mutex_t mutexId;
28 #endif
29 
31 
33 typedef struct tag_CmnThread {
34 #if IS_PRATFORM_WINDOWS()
35  HANDLE threadId;
36 #else
37  pthread_t threadId;
38 #endif
39  void (*method)(struct tag_CmnThread*);
40  void *data;
42 } CmnThread;
43 
44 D_EXTERN void CmnThread_Init(CmnThread *thread, void (*method)(CmnThread*), void *data, CmnThreadMutex *mutex);
45 D_EXTERN int CmnThread_Start(CmnThread *thread);
46 D_EXTERN void CmnThread_Join(CmnThread *thread);
47 D_EXTERN void CmnThread_Kill(CmnThread *thread);
48 
53 
54 #endif /* CMNCLIB_CMN_THREAD_H_ */
D_EXTERN void CmnThread_Kill(CmnThread *thread)
スレッド強制終了
Definition: CmnThread.c:138
struct tag_CmnThreadMutex CmnThreadMutex
D_EXTERN void CmnThreadMutex_UnLock(CmnThreadMutex *mutex)
Mutexロック解除
Definition: CmnThread.c:215
D_EXTERN void CmnThread_Join(CmnThread *thread)
スレッド処理待ち合わせ
Definition: CmnThread.c:118
D_EXTERN int CmnThread_Start(CmnThread *thread)
スレッド処理開始
Definition: CmnThread.c:58
struct tag_CmnThread CmnThread
void(* method)(struct tag_CmnThread *)
Definition: CmnThread.h:39
D_EXTERN void CmnThreadMutex_Lock(CmnThreadMutex *mutex)
Mutexロック取得
Definition: CmnThread.c:195
Definition: CmnThread.h:33
void * data
Definition: CmnThread.h:40
共通関数 メインヘッダファイル
CmnThreadMutex * mutex
Definition: CmnThread.h:41
D_EXTERN void CmnThread_Init(CmnThread *thread, void(*method)(CmnThread *), void *data, CmnThreadMutex *mutex)
スレッドオブジェクト初期化
Definition: CmnThread.c:41
D_EXTERN CmnThreadMutex * CmnThreadMutex_Create()
Mutex作成
Definition: CmnThread.c:158
pthread_mutex_t mutexId
Definition: CmnThread.h:27
pthread_t threadId
Definition: CmnThread.h:37
Definition: CmnThread.h:23
D_EXTERN void CmnThreadMutex_Free(CmnThreadMutex *mutex)
Mutex破棄
Definition: CmnThread.c:235