// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _OSD_Semaphore_HeaderFile #define _OSD_Semaphore_HeaderFile #ifndef _Standard_HeaderFile #include #endif #ifndef _Standard_Macro_HeaderFile #include #endif #ifndef _TCollection_AsciiString_HeaderFile #include #endif #ifndef _Standard_Integer_HeaderFile #include #endif #ifndef _OSD_Error_HeaderFile #include #endif #ifndef _Standard_Boolean_HeaderFile #include #endif class Standard_ConstructionError; class OSD_OSDError; class Standard_ProgramError; class TCollection_AsciiString; //! IPC Tools -Semaphores
//! The semaphores are used to facilitate shared resources.
//! This implementation provides a way to ensure mutual
//! exclusion using 'Lock' and 'Free' primitives.
//! The Lock is used to prevent access if it's not yet allowed.
//! The Free validates the semaphores and if possible, frees process
//! waiting for a common resource.
class OSD_Semaphore { public: void* operator new(size_t,void* anAddress) { return anAddress; } void* operator new(size_t size) { return Standard::Allocate(size); } void operator delete(void *anAddress) { if (anAddress) Standard::Free((Standard_Address&)anAddress); } //! Allocate room for semaphore name.
//! This is to be used with 'Open'.
//! so the process is a client.
Standard_EXPORT OSD_Semaphore(); //! Instantiates Semaphore object with a name.
//! The name is the only way provided to work with a common
//! semaphore for different processes.
//! Each process working with the same semaphore must use
//! a common known access : the semaphore's NAME.
//! Raises ConstructionError when the name contains characters
//! not in range of ' '...'~'.
//! This is for a server process.
Standard_EXPORT OSD_Semaphore(const TCollection_AsciiString& Name); //! Sets semaphore (physically) into memory
Standard_EXPORT void Build() ; //! Opens (physically) a semaphore
//! Raises ConstructionError when the name contains characters
//! not in range of ' '...'~'.
Standard_EXPORT void Open(const TCollection_AsciiString& Name) ; //! Returns current value of the semaphore's counter.
//! Raises ProgramError when the semaphore is not open.
Standard_EXPORT Standard_Integer GetCounter() ; //! Sets the semaphore's counter to a specific value.
//! Raises ProgramError when the semaphore is not open.
Standard_EXPORT void SetCounter(const Standard_Integer Value) ; //! Removes the semaphore.
//! This is used only by server process !
//! Raise ProgramError if the semaphore is already deleted.
Standard_EXPORT void Delete() ; //! Makes current process waiting for access
//! Raises ProgramError when the semaphore does't exist.
Standard_EXPORT void Lock() ; //! Frees one access to a semaphore.
//! Raises ProgramError when the semaphore does't exist.
Standard_EXPORT void Free() ; //! Resets semaphore counter to zero.
//! Raises ProgramError when the semaphore does't exist.
Standard_EXPORT void Restore() ; //! Returns TRUE if an error occurs
Standard_EXPORT Standard_Boolean Failed() const; //! Resets error counter to zero
Standard_EXPORT void Reset() ; //! Raises OSD_Error
Standard_EXPORT void Perror() ; //! Returns error number if 'Failed' is TRUE.
Standard_EXPORT Standard_Integer Error() const; protected: private: TCollection_AsciiString myName; Standard_Integer myKey; Standard_Integer mySemId; OSD_Error myError; }; // other Inline functions and methods (like "C++: function call" methods) #endif