ansi/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_ANSI_H
00024 #define _DWFCORE_MUTEX_ANSI_H
00025 
00044 
00045 #include "dwfcore/Core.h"
00046 
00047 #ifdef  _DWFCORE_FOR_ANSI_SYSTEM_ONLY
00048 
00049 #ifndef _DWFCORE_SYNCHRONIZATION_H
00050 #error  This header should not be included directly - use "dwfcore/Synchronization.h" instead
00051 #endif
00052 
00053 //
00054 // POSIX threads 
00055 //
00056 #include <pthread.h>
00057 
00058 
00059 
00060 namespace DWFCore
00061 {
00062 
00076 class DWFThreadMutex : public DWFSynchronization
00077 {
00078 
00079 public:
00080 
00086     _DWFCORE_API
00087     DWFThreadMutex()
00088         throw();
00089 
00095     _DWFCORE_API
00096     virtual ~DWFThreadMutex()
00097         throw();
00098 
00099     //
00100     // Initialize the mutex
00101     //
00102     _DWFCORE_API void init()
00103         throw( DWFException );
00104 
00105     //
00106     // Destroy the synchronization object
00107     //
00108     _DWFCORE_API void destroy()
00109         throw( DWFException );
00110 
00111     //
00112     // Blocking call to acquire ownership of the mutex
00113     //
00114     _DWFCORE_API void lock()
00115         throw( DWFException );
00116 
00117     //
00118     // Non-blocking call to acquire ownership of the mutex
00119     //
00120     _DWFCORE_API bool trylock()
00121         throw( DWFException );
00122 
00123     //
00124     // Release ownership of the mutex
00125     //
00126     _DWFCORE_API void unlock()
00127         throw( DWFException );
00128 
00129 private:
00130 
00131     bool                   _bInit;
00132     pthread_mutex_t        _tMutex;
00133 
00134 private:
00135 
00136     //
00137     // Not Implemented
00138     //
00139     DWFThreadMutex( const DWFThreadMutex& );
00140     DWFThreadMutex& operator=( const DWFThreadMutex& );
00141 };
00142 
00143 
00144 //
00145 // no implementation for cross-process mutex yet
00146 //
00147 
00148 }
00149 
00150 
00151 #else
00152 #error  This header file is incompatible with your current system configuration
00153 #endif
00154 
00155 #endif
00156 
00157 

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