Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/Thread.h

Issue 10026001: Cross-platform thread primitives (Closed)
Patch Set: Don't unlock/signal mutices/conditions, move Mutex and Condition to the top level Created April 4, 2013, 2:52 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/Thread.cpp » ('j') | test/Thread.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/Thread.h
===================================================================
--- a/src/Thread.h
+++ b/src/Thread.h
@@ -9,40 +9,40 @@
namespace AdblockPlus
{
+ class Mutex
+ {
+ public:
+#ifdef WIN32
+ CRITICAL_SECTION nativeMutex;
+#else
+ pthread_mutex_t nativeMutex;
+#endif
+
+ Mutex();
+ ~Mutex();
+ void Lock();
+ void Unlock();
+ };
+
+ class ConditionVariable
+ {
+ public:
+ ConditionVariable();
+ ~ConditionVariable();
+ void Wait(Mutex& mutex);
+ void Signal();
+
+ private:
+#ifdef WIN32
+ CONDITION_VARIABLE nativeCondition;
+#else
+ pthread_cond_t nativeCondition;
+#endif
+ };
+
class Thread
{
public:
- class Mutex
- {
- 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
- CONDITION_VARIABLE nativeCondition;
-#else
- pthread_cond_t nativeCondition;
-#endif
- };
-
virtual ~Thread();
virtual void Run() = 0;
void Start();
@@ -50,9 +50,9 @@
private:
#ifdef WIN32
- HANDLE thread;
+ HANDLE nativeThread;
#else
- pthread_t thread;
+ pthread_t nativeThread;
#endif
};
}
« no previous file with comments | « no previous file | src/Thread.cpp » ('j') | test/Thread.cpp » ('J')

Powered by Google App Engine
This is Rietveld