# FoundationClasses
TKernel
OSD

# OSD_Semaphore Class Reference

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.
.

`#include <OSD_Semaphore.hxx>`

## Public Member Functions

void * | operator new (size_t, void *anAddress)
void * | operator new (size_t size)
void | operator delete (void *anAddress)
Standard_EXPORT | OSD_Semaphore ()
| Allocate room for semaphore name. This is to be used with 'Open'. so the process is a client. .
Standard_EXPORT | OSD_Semaphore (const TCollection_AsciiString &Name)
| 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 void | Build ()
| Sets semaphore (physically) into memory .
Standard_EXPORT void | Open (const TCollection_AsciiString &Name)
| Opens (physically) a semaphore Raises ConstructionError when the name contains characters not in range of ' '...'~'. .
Standard_EXPORT Standard_Integer | GetCounter ()
| Returns current value of the semaphore's counter. Raises ProgramError when the semaphore is not open. .
Standard_EXPORT void | SetCounter (const Standard_Integer Value)
| Sets the semaphore's counter to a specific value. Raises ProgramError when the semaphore is not open. .
Standard_EXPORT void | Delete ()
| Removes the semaphore. This is used only by server process ! Raise ProgramError if the semaphore is already deleted. .
Standard_EXPORT void | Lock ()
| Makes current process waiting for access Raises ProgramError when the semaphore does't exist. .
Standard_EXPORT void | Free ()
| Frees one access to a semaphore. Raises ProgramError when the semaphore does't exist. .
Standard_EXPORT void | Restore ()
| Resets semaphore counter to zero. Raises ProgramError when the semaphore does't exist. .
Standard_EXPORT Standard_Boolean | Failed () const
| Returns TRUE if an error occurs .
Standard_EXPORT void | Reset ()
| Resets error counter to zero .
Standard_EXPORT void | Perror ()
| Raises OSD_Error .
Standard_EXPORT Standard_Integer | Error () const
| Returns error number if 'Failed' is TRUE. .

## Private Attributes

TCollection_AsciiString | myName
Standard_Integer | myKey
Standard_Integer | mySemId
OSD_Error | myError

## Constructor & Destructor Documentation

Standard_EXPORT OSD_Semaphore::OSD_Semaphore | ( |  | ) |

Standard_EXPORT OSD_Semaphore::OSD_Semaphore | ( | const TCollection_AsciiString & | Name | ) |

## Member Function Documentation

Standard_EXPORT void OSD_Semaphore::Build | ( |  | ) |

Standard_EXPORT void OSD_Semaphore::Delete | ( |  | ) |

Standard_EXPORT Standard_Integer OSD_Semaphore::Error | ( |  | ) | const

Standard_EXPORT Standard_Boolean OSD_Semaphore::Failed | ( |  | ) | const

Standard_EXPORT void OSD_Semaphore::Free | ( |  | ) |

Standard_EXPORT Standard_Integer OSD_Semaphore::GetCounter | ( |  | ) |

Standard_EXPORT void OSD_Semaphore::Lock | ( |  | ) |

Standard_EXPORT void OSD_Semaphore::Open | ( | const TCollection_AsciiString & | Name | ) |

void OSD_Semaphore::operator delete | ( | void * | anAddress | ) | `[inline]`

void* OSD_Semaphore::operator new | ( | size_t | size | ) | `[inline]`

void* OSD_Semaphore::operator new | ( | size_t | ,
|  | void * | anAddress
| ) | `[inline]`

Standard_EXPORT void OSD_Semaphore::Perror | ( |  | ) |

Standard_EXPORT void OSD_Semaphore::Reset | ( |  | ) |

Standard_EXPORT void OSD_Semaphore::Restore | ( |  | ) |

Standard_EXPORT void OSD_Semaphore::SetCounter | ( | const Standard_Integer | Value | ) |

## Field Documentation

OSD_Error OSD_Semaphore::myError `[private]`

Standard_Integer OSD_Semaphore::myKey `[private]`

TCollection_AsciiString OSD_Semaphore::myName `[private]`

Standard_Integer OSD_Semaphore::mySemId `[private]`

The documentation for this class was generated from the following file:

- OSD_Semaphore.hxx