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

Side by Side Diff: src/Thread.cpp

Issue 10026001: Cross-platform thread primitives (Closed)
Patch Set: Renamed thread to nativeThread, made the tests more robust Created April 3, 2013, 4:23 p.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 | « src/Thread.h ('k') | test/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 #include "Thread.h" 1 #include "Thread.h"
2 2
3 using namespace AdblockPlus; 3 using namespace AdblockPlus;
4 4
5 namespace 5 namespace
6 { 6 {
7 void CallRun(Thread* thread) 7 void CallRun(Thread* thread)
8 { 8 {
9 thread->Run(); 9 thread->Run();
10 } 10 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 #endif 82 #endif
83 } 83 }
84 84
85 Thread::~Thread() 85 Thread::~Thread()
86 { 86 {
87 } 87 }
88 88
89 void Thread::Start() 89 void Thread::Start()
90 { 90 {
91 #ifdef WIN32 91 #ifdef WIN32
92 thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&CallRun, this, 0, 0); 92 nativeThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&CallRun, this, 0, 0 );
93 #else 93 #else
94 pthread_create(&thread, 0, (void *(*)(void*)) &CallRun, this); 94 pthread_create(&nativeThread, 0, (void *(*)(void*)) &CallRun, this);
95 #endif 95 #endif
96 } 96 }
97 97
98 void Thread::Join() 98 void Thread::Join()
99 { 99 {
100 #ifdef WIN32 100 #ifdef WIN32
101 WaitForSingleObject(thread, INFINITE); 101 WaitForSingleObject(nativeThread, INFINITE);
102 #else 102 #else
103 pthread_join(thread, 0); 103 pthread_join(nativeThread, 0);
104 #endif 104 #endif
105 } 105 }
OLDNEW
« no previous file with comments | « src/Thread.h ('k') | test/Thread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld