Index: src/Thread.h |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/src/Thread.h |
@@ -0,0 +1,59 @@ |
+#ifndef ADBLOCKPLUS_THREAD_H |
+#define ADBLOCKPLUS_THREAD_H |
+ |
+#ifdef WIN32 |
+#include <windows.h> |
+#else |
+#include <pthread.h> |
+#endif |
+ |
+namespace AdblockPlus |
+{ |
+ class Thread |
+ { |
+ public: |
+ class Mutex |
Wladimir Palant
2013/04/03 13:14:47
Why not make that class public? I think it will be
Felix Dahlke
2013/04/03 16:27:59
It is public, just nested in Thread. Would you pre
Wladimir Palant
2013/04/03 19:30:16
AdblockPlus::Thread::Mutex just sounds wrong - it
Felix Dahlke
2013/04/04 02:52:58
Sure, moved them to the top level.
|
+ { |
+ public: |
+#ifdef WIN32 |
+ CRITICAL_SECTION nativeMutex; |
+#else |
+ pthread_mutex_t nativeMutex; |
+#endif |
+ |
+ Mutex(); |
+ ~Mutex(); |
+ void Lock(); |
+ void Unlock(); |
+ }; |
+ |
+ class Condition |
+ { |
+ public: |
+ Condition(); |
+ ~Condition(); |
+ void Wait(Mutex& mutex); |
+ void Signal(); |
+ |
+ private: |
+#ifdef WIN32 |
Wladimir Palant
2013/04/03 13:14:47
CONDITION_VARIABLE nativeCondition; missing here?
Felix Dahlke
2013/04/03 16:27:59
Yes, somehow messed up the patch it seems, Oleksan
|
+#else |
+ pthread_cond_t nativeCondition; |
+#endif |
+ }; |
+ |
+ virtual ~Thread(); |
+ virtual void Run() = 0; |
+ void Start(); |
+ void Join(); |
+ |
+ private: |
+#ifdef WIN32 |
+ HANDLE thread; |
Wladimir Palant
2013/04/03 13:14:47
Rename this into nativeThread for consistency?
Felix Dahlke
2013/04/03 16:27:59
Absolutely, done.
|
+#else |
+ pthread_t thread; |
+#endif |
+ }; |
+} |
+ |
+#endif |