-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgwthread.h
More file actions
64 lines (51 loc) · 2.4 KB
/
gwthread.h
File metadata and controls
64 lines (51 loc) · 2.4 KB
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
/*----------------------------------------------------------------------
| gwthread.h
|
| This file contains the headers and definitions that are used to implement
| multi-threading. Specifically, threads, mutexes, and events.
|
| Gwnum math routines use these routines to implement multi-threaded
| multiplications. However, you can use these routines without using
| the rest of the gwnum package if you so desire.
|
| NOTE: MFC users may not be able to use the thread creation routines as
| because we call the C runtime library thread create rather than the
| MFC thread create routine.
|
| Copyright 2006 Mersenne Research, Inc. All rights reserved.
+---------------------------------------------------------------------*/
#ifndef _GWTHREAD_H
#define _GWTHREAD_H
/* This is a C library. If used in a C++ program, don't let the C++ */
/* compiler mangle names. */
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* Mutex and Events Routines *
******************************************************************************/
typedef void *gwmutex; /* Definition of a mutex */
void gwmutex_init (gwmutex *mutex); /* Mutex to init */
void gwmutex_lock (gwmutex *mutex); /* Mutex to lock */
void gwmutex_unlock (gwmutex *mutex); /* Mutex to unlock */
void gwmutex_destroy (gwmutex *mutex); /* Mutex to destroy */
typedef void *gwevent; /* Definition of an event handle */
void gwevent_init (gwevent *event); /* Event to init */
#define GWEVENT_TIMED_OUT 1
#define GWEVENT_SIGNALED 2
int gwevent_wait (gwevent *event, int seconds);
void gwevent_signal (gwevent *event); /* Event to signal */
void gwevent_reset (gwevent *event); /* Event to reset */
void gwevent_destroy (gwevent *event); /* Event to destroy */
/******************************************************************************
* Thread Routines *
******************************************************************************/
typedef void *gwthread; /* Definition of a thread handle */
void gwthread_create (gwthread *thread_id, void (*thread_proc)(void *), void *arg);
void gwthread_create_waitable (gwthread *thread_id, void (*thread_proc)(void *), void *arg);
void gwthread_wait_for_exit (gwthread *thread_id);
void gwthread_kill (gwthread *thread_id);
#ifdef __cplusplus
}
#endif
#endif