Etterna 0.74.4
Loading...
Searching...
No Matches
Threads_Pthreads.h
1#ifndef THREADS_PTHREADS_H
2#define THREADS_PTHREADS_H
3
4#include "Threads.h"
5
6#include <pthread.h>
7#include <semaphore.h>
8
10{
11 public:
12 pthread_t thread;
13
14 /* Linux:
15 * Keep a list of child PIDs, so we can send them SIGKILL. This has
16 * an added bonus: if this is corrupted, we'll just send signals and
17 * they'll fail; we won't blow up (unless we're root). */
18 uint64_t threadHandle;
19
20 // These are only used during initialization.
21 int (*m_pFunc)(void* pData);
22 void* m_pData;
23 uint64_t* m_piThreadID;
24 SemaImpl* m_StartFinishedSem;
25
26 void Halt(bool Kill);
27 void Resume();
28 uint64_t GetThreadId() const;
29 int Wait();
30};
31
33{
34 friend class EventImpl_Pthreads;
35
36 public:
39
40 bool Lock();
41 bool TryLock();
42 void Unlock();
43
44 protected:
45 pthread_mutex_t mutex;
46};
47
49{
50 public:
53
54 bool Wait(float timeout);
55 void Signal();
56 void Broadcast();
57 bool WaitTimeoutSupported() const;
58
59 private:
60 MutexImpl_Pthreads* m_pParent;
61 pthread_cond_t m_Cond;
62};
63
64#if 0
65class SemaImpl_Pthreads: public SemaImpl
66{
67public:
68 SemaImpl_Pthreads( int iInitialValue );
70 int GetValue() const;
71 void Post();
72 bool Wait();
73 bool TryWait();
74
75private:
76 sem_t sem;
77};
78#else
80{
81 public:
82 SemaImpl_Pthreads(int iInitialValue);
84 int GetValue() const { return m_iValue; }
85 void Post();
86 bool Wait();
87 bool TryWait();
88
89 private:
90 pthread_cond_t m_Cond;
91 pthread_mutex_t m_Mutex;
92 unsigned m_iValue;
93};
94
95#endif
96
97#endif
Definition Threads_Pthreads.h:49
Definition Threads.h:55
Definition Threads_Pthreads.h:33
Definition Threads.h:25
Definition RageThreads.h:232
Definition Threads_Pthreads.h:80
Definition Threads.h:65
Definition Threads_Pthreads.h:10
Definition Threads.h:9