Annotation of truecrypt/platform/mutex.h, revision 1.1.1.7

1.1       root        1: /*
1.1.1.6   root        2:  Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
1.1       root        3: 
1.1.1.7 ! root        4:  Governed by the TrueCrypt License 3.0 the full text of which is contained in
1.1.1.6   root        5:  the file License.txt included in TrueCrypt binary and source code distribution
                      6:  packages.
1.1       root        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:        {
1.1.1.2   root       23: #ifdef TC_WINDOWS
                     24:                typedef CRITICAL_SECTION SystemMutex_t;
                     25: #else
                     26:                typedef pthread_mutex_t SystemMutex_t;
                     27: #endif
                     28: 
1.1       root       29:        public:
                     30:                Mutex ();
                     31:                ~Mutex ();
                     32: 
1.1.1.2   root       33:                SystemMutex_t *GetSystemHandle () { return &SystemMutex; }
1.1       root       34:                void Lock ();
                     35:                void Unlock ();
                     36: 
                     37:        protected:
                     38:                bool Initialized;
1.1.1.2   root       39:                SystemMutex_t SystemMutex;
1.1       root       40: 
                     41:        private:
                     42:                Mutex (const Mutex &);
                     43:                Mutex &operator= (const Mutex &);
                     44:        };
                     45: 
                     46:        class ScopeLock
                     47:        {
                     48:        public:
                     49:                ScopeLock (Mutex &mutex) : ScopeMutex (mutex) { mutex.Lock(); }
                     50:                ~ScopeLock () { ScopeMutex.Unlock(); }
                     51: 
                     52:        protected:
                     53:                Mutex &ScopeMutex;
                     54: 
                     55:        private:
                     56:                ScopeLock (const ScopeLock &);
                     57:                ScopeLock &operator= (const ScopeLock &);
                     58:        };
                     59: }
                     60: 
                     61: #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.