|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Counting semaphore, optionally named for cross-process use. More...
#include <Utils.h>
Public Member Functions | |
| Semaphore (uint32 maxCount=100) | |
| Create an anonymous semaphore. | |
| Semaphore (const char *name, uint32 maxCount=100) | |
| Create or open a named, cross-process semaphore. | |
| ~Semaphore () | |
| bool | wait () |
| Block until the semaphore can be decremented. | |
| bool | wait (uint32 timeout) |
| Wait with a timeout. | |
| bool | signal () |
| Increment (release) the semaphore, waking one waiter. | |
Public Attributes | |
| char * | name |
Protected Attributes | |
| sem_t * | semaphore |
Counting semaphore, optionally named for cross-process use.
On macOS an unnamed semaphore uses libdispatch (dispatch_semaphore_t) while named ones are emulated in shared memory, because POSIX unnamed semaphores are unsupported there — hence the void* semaphore_impl member.
| cmlabs::utils::Semaphore::Semaphore | ( | uint32 | maxCount = 100 | ) |
| cmlabs::utils::Semaphore::Semaphore | ( | const char * | name, |
| uint32 | maxCount = 100 ) |
Create or open a named, cross-process semaphore.
| name | Global name. |
| maxCount | Maximum count. |
Definition at line 1897 of file Utils.cpp.
References MAXKEYNAMELEN, MAXSHMEMNAMELEN, name, semaphore, cmlabs::utils::SetSemaphoreOwnsName(), cmlabs::utils::strcpyavail(), and WINSHMEMSPACE.
| cmlabs::utils::Semaphore::~Semaphore | ( | ) |
Definition at line 1930 of file Utils.cpp.
References MAXSHMEMNAMELEN, name, semaphore, and cmlabs::utils::TakeSemaphoreOwnsName().
| bool cmlabs::utils::Semaphore::signal | ( | ) |
Increment (release) the semaphore, waking one waiter.
Definition at line 2006 of file Utils.cpp.
References name, and semaphore.
Referenced by cmlabs::utils::SignalSemaphore(), cmlabs::utils::UnitTest_SemaphoreUserDeath(), and cmlabs::utils::UnitTest_SharedNames().
| bool cmlabs::utils::Semaphore::wait | ( | ) |
Block until the semaphore can be decremented.
Definition at line 1969 of file Utils.cpp.
References name, and semaphore.
Referenced by cmlabs::utils::UnitTest_SemaphoreUserDeath(), cmlabs::utils::UnitTest_SharedNames(), and cmlabs::utils::WaitForSemaphore().
| bool cmlabs::utils::Semaphore::wait | ( | uint32 | timeout | ) |
Wait with a timeout.
| timeout | Max wait in milliseconds. |
Definition at line 1986 of file Utils.cpp.
References cmlabs::utils::CalcTimeout(), name, and semaphore.
| char* cmlabs::utils::Semaphore::name |
Definition at line 550 of file Utils.h.
Referenced by psyclone_client.remote_module.RemoteModule::_control(), psyclone_client.remote_module.RemoteModule::_do_attach(), psyclone_client.remote_module.RemoteModule::_reattach_later(), psyclone_client.remote_module.RemoteModule::_receive(), psyclone_client.remote_module.RemoteModule::post(), psyclone_client.remote_module.RemoteModule::post_confirmed(), psyclone_client.remote_module.RemoteModule::query(), psyclone_client.remote_module.RemoteModule::query_catalog(), Semaphore(), Semaphore(), signal(), psyclone_client.remote_module.Trigger::to_xml(), wait(), wait(), and ~Semaphore().
|
protected |
Definition at line 558 of file Utils.h.
Referenced by Semaphore(), Semaphore(), signal(), wait(), wait(), and ~Semaphore().