C-chat
threads.h
Go to the documentation of this file.
1 
6 #ifndef C_CHAT_THREADS_H
7 #define C_CHAT_THREADS_H
8 
9 #if defined(__unix__) || defined(__unix) || defined(unix) || defined(__APPLE__) || defined(__linux__)
10 
11 #define THREAD_RETURN_TYPE void*
12 #define THREAD_CALL_TYPE
13 
14 #elif defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS)
15 
16 #ifndef WIN32_LEAN_AND_MEAN
17 #include <windows.h>
18 #define WIN32_LEAN_AND_MEAN
19 #endif
20 
21 #define THREAD_RETURN_TYPE DWORD
22 #define THREAD_CALL_TYPE WINAPI
23 
24 #endif
25 
29 #define THREAD_ENTRY_POINT THREAD_RETURN_TYPE THREAD_CALL_TYPE
30 
31 typedef THREAD_RETURN_TYPE (THREAD_CALL_TYPE *FP_THREAD) (void*);
32 
36 typedef FP_THREAD THREAD_FUNCTION_POINTER;
37 
44 typedef struct Thread {
45  void* info;
46 } Thread;
47 
64 
70 void destroyThread(Thread* thread);
71 
77 void joinThread(Thread* thread);
78 
79 #endif //C_CHAT_THREADS_H
THREAD_FUNCTION_POINTER
FP_THREAD THREAD_FUNCTION_POINTER
The type for a valid thread entry point.
Definition: threads.h:36
destroyThread
void destroyThread(Thread *thread)
Destroys the given thread.
Thread
Represents a thread.
Definition: threads.h:44
createThread
Thread createThread(THREAD_FUNCTION_POINTER entryPoint, void *data)
Creates and starts a thread.
joinThread
void joinThread(Thread *thread)
Waits for the given thread to finish.