aboutsummaryrefslogtreecommitdiff
path: root/src/tests/threadid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/threadid.cpp')
-rw-r--r--src/tests/threadid.cpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/tests/threadid.cpp b/src/tests/threadid.cpp
index 9ff99df..dfea504 100644
--- a/src/tests/threadid.cpp
+++ b/src/tests/threadid.cpp
@@ -9,64 +9,64 @@ using namespace Bu;
9class CopyThing 9class CopyThing
10{ 10{
11public: 11public:
12 CopyThing() 12 CopyThing()
13 { 13 {
14 TRACE(); 14 TRACE();
15 tidHome = Thread::currentThread(); 15 tidHome = Thread::currentThread();
16 } 16 }
17 17
18 CopyThing( const CopyThing &rSrc ) 18 CopyThing( const CopyThing &rSrc )
19 { 19 {
20 TRACE(); 20 TRACE();
21 tidHome = Thread::currentThread(); 21 tidHome = Thread::currentThread();
22 sio << "Same thread? " << (tidHome == rSrc.tidHome) << sio.nl; 22 sio << "Same thread? " << (tidHome == rSrc.tidHome) << sio.nl;
23 } 23 }
24 24
25 void doThings() 25 void doThings()
26 { 26 {
27 TRACE(); 27 TRACE();
28 if( tidHome != Thread::currentThread() ) 28 if( tidHome != Thread::currentThread() )
29 sio << "Different threads, hard copy here." << sio.nl; 29 sio << "Different threads, hard copy here." << sio.nl;
30 else 30 else
31 sio << "Same thread, everything is cool." << sio.nl; 31 sio << "Same thread, everything is cool." << sio.nl;
32 } 32 }
33 33
34private: 34private:
35 ThreadId tidHome; 35 ThreadId tidHome;
36}; 36};
37 37
38class SubThread : public Thread 38class SubThread : public Thread
39{ 39{
40public: 40public:
41 SubThread( CopyThing &src ) : 41 SubThread( CopyThing &src ) :
42 src( src ) 42 src( src )
43 { 43 {
44 src.doThings(); 44 src.doThings();
45 } 45 }
46 46
47protected: 47protected:
48 void run() 48 void run()
49 { 49 {
50 src.doThings(); 50 src.doThings();
51 sio << "run-Child is me? " << (getId() == Thread::currentThread()) << sio.nl; 51 sio << "run-Child is me? " << (getId() == Thread::currentThread()) << sio.nl;
52 } 52 }
53 53
54private: 54private:
55 CopyThing src; 55 CopyThing src;
56}; 56};
57 57
58int main( int argc, char *argv[] ) 58int main( int argc, char *argv[] )
59{ 59{
60 CopyThing a; 60 CopyThing a;
61 61
62 SubThread st( a ); 62 SubThread st( a );
63 st.start(); 63 st.start();
64 64
65 sio << "Child is me? " << (st.getId() == Thread::currentThread()) << sio.nl; 65 sio << "Child is me? " << (st.getId() == Thread::currentThread()) << sio.nl;
66 66
67 st.join(); 67 st.join();
68 68
69 69
70 return 0; 70 return 0;
71} 71}
72 72