aboutsummaryrefslogtreecommitdiff
path: root/src/tests/threadid.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-04-09 16:29:18 +0000
committerMike Buland <eichlan@xagasoft.com>2012-04-09 16:29:18 +0000
commit228b885b41652a015a91770dfd993456d76ad102 (patch)
tree9a4b0756133fa1b7553f9aacf9ad50e7f26179d8 /src/tests/threadid.cpp
parentb93f18e1dd303fb648bc350416f7f5ace536fd1f (diff)
downloadlibbu++-228b885b41652a015a91770dfd993456d76ad102.tar.gz
libbu++-228b885b41652a015a91770dfd993456d76ad102.tar.bz2
libbu++-228b885b41652a015a91770dfd993456d76ad102.tar.xz
libbu++-228b885b41652a015a91770dfd993456d76ad102.zip
Blowfish works in it's new split form, which will make it much easier to add
other types of ciphers down the road, should we choose to.
Diffstat (limited to '')
-rw-r--r--src/tests/threadid.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/tests/threadid.cpp b/src/tests/threadid.cpp
new file mode 100644
index 0000000..9ff99df
--- /dev/null
+++ b/src/tests/threadid.cpp
@@ -0,0 +1,72 @@
1#include <bu/thread.h>
2#include <bu/sio.h>
3
4#define BU_TRACE
5#include <bu/trace.h>
6
7using namespace Bu;
8
9class CopyThing
10{
11public:
12 CopyThing()
13 {
14 TRACE();
15 tidHome = Thread::currentThread();
16 }
17
18 CopyThing( const CopyThing &rSrc )
19 {
20 TRACE();
21 tidHome = Thread::currentThread();
22 sio << "Same thread? " << (tidHome == rSrc.tidHome) << sio.nl;
23 }
24
25 void doThings()
26 {
27 TRACE();
28 if( tidHome != Thread::currentThread() )
29 sio << "Different threads, hard copy here." << sio.nl;
30 else
31 sio << "Same thread, everything is cool." << sio.nl;
32 }
33
34private:
35 ThreadId tidHome;
36};
37
38class SubThread : public Thread
39{
40public:
41 SubThread( CopyThing &src ) :
42 src( src )
43 {
44 src.doThings();
45 }
46
47protected:
48 void run()
49 {
50 src.doThings();
51 sio << "run-Child is me? " << (getId() == Thread::currentThread()) << sio.nl;
52 }
53
54private:
55 CopyThing src;
56};
57
58int main( int argc, char *argv[] )
59{
60 CopyThing a;
61
62 SubThread st( a );
63 st.start();
64
65 sio << "Child is me? " << (st.getId() == Thread::currentThread()) << sio.nl;
66
67 st.join();
68
69
70 return 0;
71}
72