From 228b885b41652a015a91770dfd993456d76ad102 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 9 Apr 2012 16:29:18 +0000 Subject: 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. --- src/tests/threadid.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/tests/threadid.cpp (limited to 'src/tests/threadid.cpp') 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 @@ +#include +#include + +#define BU_TRACE +#include + +using namespace Bu; + +class CopyThing +{ +public: + CopyThing() + { + TRACE(); + tidHome = Thread::currentThread(); + } + + CopyThing( const CopyThing &rSrc ) + { + TRACE(); + tidHome = Thread::currentThread(); + sio << "Same thread? " << (tidHome == rSrc.tidHome) << sio.nl; + } + + void doThings() + { + TRACE(); + if( tidHome != Thread::currentThread() ) + sio << "Different threads, hard copy here." << sio.nl; + else + sio << "Same thread, everything is cool." << sio.nl; + } + +private: + ThreadId tidHome; +}; + +class SubThread : public Thread +{ +public: + SubThread( CopyThing &src ) : + src( src ) + { + src.doThings(); + } + +protected: + void run() + { + src.doThings(); + sio << "run-Child is me? " << (getId() == Thread::currentThread()) << sio.nl; + } + +private: + CopyThing src; +}; + +int main( int argc, char *argv[] ) +{ + CopyThing a; + + SubThread st( a ); + st.start(); + + sio << "Child is me? " << (st.getId() == Thread::currentThread()) << sio.nl; + + st.join(); + + + return 0; +} + -- cgit v1.2.3