Annotation of truecrypt/platform/mutex.h, revision 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_Mutex
        !            10: #define TC_HEADER_Platform_Mutex
        !            11: 
        !            12: #ifdef TC_WINDOWS
        !            13: #      include "System.h"
        !            14: #else
        !            15: #      include <pthread.h>
        !            16: #endif
        !            17: #include "PlatformBase.h"
        !            18: 
        !            19: namespace TrueCrypt
        !            20: {
        !            21:        class Mutex
        !            22:        {
        !            23:        public:
        !            24:                Mutex ();
        !            25:                ~Mutex ();
        !            26: 
        !            27:                void Lock ();
        !            28:                void Unlock ();
        !            29: 
        !            30:        protected:
        !            31:                bool Initialized;
        !            32: #ifdef TC_WINDOWS
        !            33:                CRITICAL_SECTION SystemMutex;
        !            34: #else
        !            35:                pthread_mutex_t SystemMutex;
        !            36: #endif
        !            37: 
        !            38:        private:
        !            39:                Mutex (const Mutex &);
        !            40:                Mutex &operator= (const Mutex &);
        !            41:        };
        !            42: 
        !            43:        class ScopeLock
        !            44:        {
        !            45:        public:
        !            46:                ScopeLock (Mutex &mutex) : ScopeMutex (mutex) { mutex.Lock(); }
        !            47:                ~ScopeLock () { ScopeMutex.Unlock(); }
        !            48: 
        !            49:        protected:
        !            50:                Mutex &ScopeMutex;
        !            51: 
        !            52:        private:
        !            53:                ScopeLock (const ScopeLock &);
        !            54:                ScopeLock &operator= (const ScopeLock &);
        !            55:        };
        !            56: }
        !            57: 
        !            58: #endif // TC_HEADER_Platform_Mutex

unix.superglobalmegacorp.com

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