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

Side by Side Diff: src/Thread.h

Issue 10026001: Cross-platform thread primitives (Closed)
Patch Set: Created March 29, 2013, 5:26 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
OLDNEW
(Empty)
1 #ifndef ADBLOCKPLUS_THREAD_H
2 #define ADBLOCKPLUS_THREAD_H
3
4 #ifdef WIN32
5 #include <windows.h>
6 #else
7 #include <pthread.h>
8 #endif
9
10 namespace AdblockPlus
11 {
12 class Thread
13 {
14 public:
15 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.
16 {
17 public:
18 #ifdef WIN32
19 CRITICAL_SECTION nativeMutex;
20 #else
21 pthread_mutex_t nativeMutex;
22 #endif
23
24 Mutex();
25 ~Mutex();
26 void Lock();
27 void Unlock();
28 };
29
30 class Condition
31 {
32 public:
33 Condition();
34 ~Condition();
35 void Wait(Mutex& mutex);
36 void Signal();
37
38 private:
39 #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
40 #else
41 pthread_cond_t nativeCondition;
42 #endif
43 };
44
45 virtual ~Thread();
46 virtual void Run() = 0;
47 void Start();
48 void Join();
49
50 private:
51 #ifdef WIN32
52 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.
53 #else
54 pthread_t thread;
55 #endif
56 };
57 }
58
59 #endif
OLDNEW
« no previous file with comments | « libadblockplus.gyp ('k') | src/Thread.cpp » ('j') | src/Thread.cpp » ('J')

Powered by Google App Engine
This is Rietveld