ansi/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_ANSI_H
00024 #define _DWFCORE_SEMAPHORE_ANSI_H
00025 
00040 
00041 
00042 #include "dwfcore/Core.h"
00043 
00044 #ifdef  _DWFCORE_FOR_ANSI_SYSTEM_ONLY
00045 
00046 #ifndef _DWFCORE_SYNCHRONIZATION_H
00047 #error  This header should not be included directly - use "dwfcore/Synchronization.h" instead
00048 #endif
00049 
00050 #include <semaphore.h>
00051 
00052 
00053 
00054 namespace DWFCore
00055 {
00056 
00067 class DWFSemaphore : public DWFSynchronization
00068 {
00069 
00070 public:
00071 
00078     _DWFCORE_API DWFSemaphore( unsigned int nCount )
00079         throw();
00080 
00086     _DWFCORE_API virtual ~DWFSemaphore()
00087         throw();
00088 
00089     //
00090     // Initialize the semaphore
00091     //
00092     _DWFCORE_API void init()
00093         throw( DWFException );
00094 
00095     //
00096     // Destroy the semaphore
00097     //
00098     _DWFCORE_API void destroy()
00099         throw( DWFException );
00100 
00101     //
00102     // Blocking call to acquire ownership of the semaphore
00103     //
00104     _DWFCORE_API void lock()
00105         throw( DWFException );
00106 
00107     //
00108     // Non-blocking call to acquire ownership of the semaphore
00109     //
00110     _DWFCORE_API bool trylock()
00111         throw( DWFException );
00112 
00113     //
00114     // Release ownership of the semaphore
00115     //
00116     _DWFCORE_API void unlock()
00117         throw( DWFException );
00118 
00119 private:
00120 
00121     bool         _bInit;
00122     unsigned int _nCount;
00123     sem_t        _tSemaphore;
00124 
00125 private:
00126 
00127     DWFSemaphore( const DWFSemaphore& );
00128     DWFSemaphore& operator=( const DWFSemaphore& );
00129 };
00130 
00131 }
00132 
00133 
00134 #else
00135 #error  This header file is incompatible with your current system configuration
00136 #endif
00137 
00138 #endif
00139 
00140 

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