Stardew Engine
Loading...
Searching...
No Matches
Thread.h
Go to the documentation of this file.
1#ifndef STARDEW_THREAD_H
2#define STARDEW_THREAD_H
3
4#ifdef WIN32
5
6#include <windows.h>
7typedef HANDLE CrossPlatformThread;
8
9typedef DWORD(*ThreadFn)(void*);
10
11#define DECLARE_THREAD_PROC(name, argName) DWORD name (void* argName)
12
13typedef CRITICAL_SECTION CrossPlatformMutex;
14
15typedef DWORD CrossPlatformThreadID;
16
17#else
18
19#include <pthread.h>
20#define _GNU_SOURCE
21#include <unistd.h>
22#include <sys/types.h>
23
27typedef void*(*ThreadFn)(void*);
28
29typedef pthread_t CrossPlatformThread;
30
31#define DECLARE_THREAD_PROC(name, argName) void* name (void* argName)
32
34typedef pthread_mutex_t CrossPlatformMutex;
35
37
38#endif
39
40
47CrossPlatformThread StartThread(ThreadFn thread, void* pUser);
48
50
51/*
52 Mutexes
53 - These will work between threads in the same process: in windows terms, a "critical section"
54*/
55
59
63
67
71
75
76#endif
void UnlockMutex(CrossPlatformMutex *pMtx)
Definition Thread.c:90
pthread_mutex_t CrossPlatformMutex
Mutexes - These will work between threads in the same process: in windows terms, a "critical section"...
Definition Thread.h:34
pid_t CrossPlatformThreadID
Definition Thread.h:36
CrossPlatformThreadID GetThisThreadsID()
Definition Thread.c:95
void JoinThread(CrossPlatformThread pThread)
Definition Thread.c:66
void InitMutex(CrossPlatformMutex *pMtx)
Definition Thread.c:72
void *(* ThreadFn)(void *)
Thread functions have return values as required by the OS thread libs but as the win32 thead returns ...
Definition Thread.h:27
void LockMutex(CrossPlatformMutex *pMtx)
Definition Thread.c:85
pthread_t CrossPlatformThread
Definition Thread.h:29
CrossPlatformThread StartThread(ThreadFn thread, void *pUser)
Thread functions have return values as required by the OS thread libs but as the win32 thead returns ...
Definition Thread.c:59
void DestroyMutex(CrossPlatformMutex *pMtx)
Definition Thread.c:80