Annotation of truecrypt/platform/thread.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
                      3: 
                      4:  Governed by the TrueCrypt License 2.4 the full text of which is contained
                      5:  in the file License.txt included in TrueCrypt binary and source code
                      6:  distribution packages.
                      7: */
                      8: 
                      9: #ifndef TC_HEADER_Platform_Thread
                     10: #define TC_HEADER_Platform_Thread
                     11: 
                     12: #ifdef TC_WINDOWS
                     13: #      include "System.h"
                     14: #      define TC_THREAD_PROC DWORD WINAPI
                     15: #else
                     16: #      include <pthread.h>
                     17: #      define TC_THREAD_PROC void*
                     18: #endif
                     19: #include "PlatformBase.h"
                     20: #include "Functor.h"
                     21: #include "SharedPtr.h"
                     22: 
                     23: namespace TrueCrypt
                     24: {
                     25:        class Thread
                     26:        {
                     27:        public:
                     28: #ifdef TC_WINDOWS
                     29:                typedef LPTHREAD_START_ROUTINE ThreadProcPtr;
                     30: #else
                     31:                typedef void* (*ThreadProcPtr) (void *);
                     32: #endif
                     33:                Thread () { };
                     34:                virtual ~Thread () { };
                     35: 
                     36:                void Start (ThreadProcPtr threadProc, void *parameter = nullptr);
                     37: 
                     38:                void Start (Functor *functor)
                     39:                {
                     40:                        Start (Thread::FunctorEntry, (void *)functor);
                     41:                }
                     42: 
                     43:                static void Sleep (uint32 milliSeconds);
                     44: 
                     45:        protected:
                     46:                static TC_THREAD_PROC FunctorEntry (void *functorArg)
                     47:                {
                     48:                        Functor *functor = (Functor *) functorArg;
                     49:                        try
                     50:                        {
                     51:                                (*functor) ();
                     52:                        }
                     53:                        catch (...) { }
                     54: 
                     55:                        delete functor;
                     56:                        return 0;
                     57:                }
                     58: 
                     59:                static const size_t MinThreadStackSize = 1024 * 1024;
                     60: 
                     61:        private:
                     62:                Thread (const Thread &);
                     63:                Thread &operator= (const Thread &);
                     64:        };
                     65: 
                     66: }
                     67: 
                     68: #endif // TC_HEADER_Platform_Thread

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.