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

Side by Side Diff: src/Thread.h

Issue 10105002: Add Sleep and Lock utilities (Closed)
Patch Set: Created April 4, 2013, 5:34 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/Thread.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifndef ADBLOCKPLUS_THREAD_H 1 #ifndef ADBLOCKPLUS_THREAD_H
2 #define ADBLOCKPLUS_THREAD_H 2 #define ADBLOCKPLUS_THREAD_H
3 3
4 #ifdef WIN32 4 #ifdef WIN32
5 #include <windows.h> 5 #include <windows.h>
6 #else 6 #else
7 #include <pthread.h> 7 #include <pthread.h>
8 #endif 8 #endif
9 9
10 namespace AdblockPlus 10 namespace AdblockPlus
11 { 11 {
12 void Sleep(const int millis);
13
12 class Mutex 14 class Mutex
13 { 15 {
14 public: 16 public:
15 #ifdef WIN32 17 #ifdef WIN32
16 CRITICAL_SECTION nativeMutex; 18 CRITICAL_SECTION nativeMutex;
17 #else 19 #else
18 pthread_mutex_t nativeMutex; 20 pthread_mutex_t nativeMutex;
19 #endif 21 #endif
20 22
21 Mutex(); 23 Mutex();
22 ~Mutex(); 24 ~Mutex();
23 void Lock(); 25 void Lock();
24 void Unlock(); 26 void Unlock();
25 }; 27 };
26 28
29 class Lock
30 {
31 public:
32 Lock(Mutex& mutex);
33 ~Lock();
34
35 private:
36 Mutex& mutex;
37 };
38
27 class ConditionVariable 39 class ConditionVariable
28 { 40 {
29 public: 41 public:
30 ConditionVariable(); 42 ConditionVariable();
31 ~ConditionVariable(); 43 ~ConditionVariable();
32 void Wait(Mutex& mutex); 44 void Wait(Mutex& mutex);
33 void Signal(); 45 void Signal();
34 46
35 private: 47 private:
36 #ifdef WIN32 48 #ifdef WIN32
(...skipping 14 matching lines...) Expand all
51 private: 63 private:
52 #ifdef WIN32 64 #ifdef WIN32
53 HANDLE nativeThread; 65 HANDLE nativeThread;
54 #else 66 #else
55 pthread_t nativeThread; 67 pthread_t nativeThread;
56 #endif 68 #endif
57 }; 69 };
58 } 70 }
59 71
60 #endif 72 #endif
OLDNEW
« no previous file with comments | « no previous file | src/Thread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld