win32/Mutex.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2003-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 
00023 #ifndef _DWFCORE_MUTEX_WIN32_H
00024 #define _DWFCORE_MUTEX_WIN32_H
00025 
00026 
00043 
00044 
00045 #include "dwfcore/Core.h"
00046 
00047 #ifdef  _DWFCORE_WIN32_SYSTEM
00048 
00049 #ifndef _DWFCORE_SYNCHRONIZATION_H
00050 #error  This header should not be included directly - use "core/Synchronization.h" instead
00051 #endif
00052 
00053 
00054 namespace DWFCore
00055 {
00056 
00071 class DWFThreadMutex : virtual public DWFCoreMemory
00072                      , public DWFSynchronization
00073 {
00074 
00075 public:
00076 
00082     _DWFCORE_API 
00083     DWFThreadMutex()
00084         throw();
00085 
00091     _DWFCORE_API 
00092     virtual ~DWFThreadMutex()
00093         throw();
00094 
00095     //
00096     // Initialize the mutex
00097     //
00098     _DWFCORE_API 
00099     void init()
00100         throw( DWFException );
00101 
00102     //
00103     // Destroy the mutex
00104     //
00105     _DWFCORE_API 
00106     void destroy()
00107         throw( DWFException );
00108 
00109     //
00110     // Blocking call to acquire ownership of the mutex
00111     //
00112     _DWFCORE_API 
00113     void lock()
00114         throw( DWFException );
00115 
00116     //
00117     // Non-blocking call to acquire ownership of the mutex
00118     //
00119     _DWFCORE_API 
00120     bool trylock()
00121         throw( DWFException );
00122 
00123     //
00124     // Release ownership of the mutex
00125     //
00126     _DWFCORE_API 
00127     void unlock()
00128         throw( DWFException );
00129 
00130 private:
00131 
00132     bool                _bInit;
00133     CRITICAL_SECTION    _tSection;
00134 
00135 private:
00136 
00137     DWFThreadMutex( const DWFThreadMutex& );
00138     DWFThreadMutex& operator=( const DWFThreadMutex& );
00139 };
00140 
00141 
00157 class DWFProcessMutex : virtual public DWFCoreMemory
00158                       , public DWFSynchronization
00159 {
00160 
00161 public:
00162 
00169     _DWFCORE_API 
00170     DWFProcessMutex( const DWFString& zName )
00171         throw();
00172 
00178     _DWFCORE_API 
00179     virtual ~DWFProcessMutex()
00180         throw();
00181 
00182     //
00183     // Initialize the mutex
00184     //
00185     _DWFCORE_API 
00186     void init()
00187         throw( DWFException );
00188 
00189     //
00190     // Destroy the mutex
00191     //
00192     _DWFCORE_API 
00193     void destroy()
00194         throw( DWFException );
00195 
00196     //
00197     // Blocking call to acquire ownership of the mutex
00198     //
00199     _DWFCORE_API 
00200     void lock()
00201         throw( DWFException );
00202 
00203     //
00204     // Non-blocking call to acquire ownership of the mutex
00205     //
00206     _DWFCORE_API 
00207     bool trylock()
00208         throw( DWFException );
00209 
00210     //
00211     // Release ownership of the mutex
00212     //
00213     _DWFCORE_API 
00214     void unlock()
00215         throw( DWFException );
00216 
00223     _DWFCORE_API 
00224     const DWFString& name() const
00225         throw();
00226 
00227 private:
00228 
00229     bool        _bInit;
00230     HANDLE      _hMutex;
00231     DWFString   _zName;
00232 
00233 private:
00234 
00235     //
00236     // Not Implemented
00237     //
00238 
00239     DWFProcessMutex( const DWFProcessMutex& );
00240     DWFProcessMutex& operator=( const DWFProcessMutex& );
00241 };
00242 
00243 }
00244 
00245 
00246 #else
00247 #error  This is a Win32 header file and is incompatible with your current system configuration
00248 #endif 
00249 
00250 #endif
00251 
00252 

Generated on Tue Jan 6 22:39:29 2009 for Autodesk DWF Core Library by  doxygen 1.4.5