diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-04-09 16:29:18 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-04-09 16:29:18 +0000 |
commit | 228b885b41652a015a91770dfd993456d76ad102 (patch) | |
tree | 9a4b0756133fa1b7553f9aacf9ad50e7f26179d8 /src/tests/threadid.cpp | |
parent | b93f18e1dd303fb648bc350416f7f5ace536fd1f (diff) | |
download | libbu++-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 'src/tests/threadid.cpp')
-rw-r--r-- | src/tests/threadid.cpp | 72 |
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 | |||
7 | using namespace Bu; | ||
8 | |||
9 | class CopyThing | ||
10 | { | ||
11 | public: | ||
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 | |||
34 | private: | ||
35 | ThreadId tidHome; | ||
36 | }; | ||
37 | |||
38 | class SubThread : public Thread | ||
39 | { | ||
40 | public: | ||
41 | SubThread( CopyThing &src ) : | ||
42 | src( src ) | ||
43 | { | ||
44 | src.doThings(); | ||
45 | } | ||
46 | |||
47 | protected: | ||
48 | void run() | ||
49 | { | ||
50 | src.doThings(); | ||
51 | sio << "run-Child is me? " << (getId() == Thread::currentThread()) << sio.nl; | ||
52 | } | ||
53 | |||
54 | private: | ||
55 | CopyThing src; | ||
56 | }; | ||
57 | |||
58 | int 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 | |||