win32/Semaphore.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_SEMAPHORE_WIN32_H
00024 #define _DWFCORE_SEMAPHORE_WIN32_H
00025 
00026 
00040 
00041 
00042 #include "dwfcore/Core.h"
00043 
00044 #ifdef  _DWFCORE_WIN32_SYSTEM
00045 
00046 #ifndef _DWFCORE_SYNCHRONIZATION_H
00047 #error  This header should not be included directly - use "dwfcore/Synchronization.h" instead
00048 #endif
00049 
00050 
00051 namespace DWFCore
00052 {
00053 
00064 class DWFSemaphore : virtual public DWFCoreMemory
00065                    , public DWFSynchronization
00066 {
00067 
00068 public:
00069 
00076     _DWFCORE_API 
00077     DWFSemaphore( unsigned int nCount )
00078         throw();
00079 
00085     _DWFCORE_API 
00086     virtual ~DWFSemaphore()
00087         throw();
00088 
00089     //
00090     // Initialize the semaphore
00091     //
00092     _DWFCORE_API 
00093     void init()
00094         throw( DWFException );
00095 
00096     //
00097     // Destroy the semaphore
00098     //
00099     _DWFCORE_API 
00100     void destroy()
00101         throw( DWFException );
00102 
00103     //
00104     // Blocking call to acquire ownership of the semaphore
00105     //
00106     _DWFCORE_API 
00107     void lock()
00108         throw( DWFException );
00109 
00110     //
00111     // Non-blocking call to acquire ownership of the semaphore
00112     //
00113     _DWFCORE_API 
00114     bool trylock()
00115         throw( DWFException );
00116 
00117     //
00118     // Release ownership of the semaphore
00119     //
00120     _DWFCORE_API 
00121     void unlock()
00122         throw( DWFException );
00123 
00124 private:
00125 
00126     bool         _bInit;
00127     unsigned int _nCount;
00128 
00129     HANDLE       _hSemaphore;
00130 
00131 private:
00132 
00133     //
00134     // Not Implemented
00135     //
00136 
00137     DWFSemaphore( const DWFSemaphore& );
00138     DWFSemaphore& operator=( const DWFSemaphore& );
00139 };
00140 
00141 }
00142 
00143 
00144 
00145 #else
00146 #error  This is a Win32 header file and is incompatible with your current system configuration
00147 #endif 
00148 
00149 #endif
00150 
00151 

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