YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
shmem::NamedSemaphore Class Reference

A named inter-process semaphore. More...

#include <shmem_carrier/ShmemPlatform.h>

Public Member Functions

 NamedSemaphore ()=default
 
 ~NamedSemaphore ()
 
 NamedSemaphore (const NamedSemaphore &)=delete
 
NamedSemaphore & operator= (const NamedSemaphore &)=delete
 
bool create (const std::string &name, unsigned int initial, unsigned int max)
 Create a new semaphore (removing any stale semaphore with the same name)
 
bool open (const std::string &name)
 Open an existing semaphore.
 
void close ()
 
bool wait ()
 Wait until the semaphore is available.
 
bool waitFor (double timeout)
 Wait at most timeout seconds. Returns true if the semaphore was acquired.
 
bool post ()
 

Static Public Member Functions

static void unlink (const std::string &name)
 Remove the name of the semaphore (no-op on Windows)
 

Detailed Description

A named inter-process semaphore.

Unlike a process mutex, it can be released by any thread of any process.

Definition at line 63 of file ShmemPlatform.h.

Constructor & Destructor Documentation

◆ NamedSemaphore() [1/2]

shmem::NamedSemaphore::NamedSemaphore ( )
default

◆ ~NamedSemaphore()

shmem::NamedSemaphore::~NamedSemaphore ( )

Definition at line 328 of file ShmemPlatform.cpp.

◆ NamedSemaphore() [2/2]

shmem::NamedSemaphore::NamedSemaphore ( const NamedSemaphore &  )
delete

Member Function Documentation

◆ close()

void shmem::NamedSemaphore::close ( )

Definition at line 438 of file ShmemPlatform.cpp.

◆ create()

bool shmem::NamedSemaphore::create ( const std::string &  name,
unsigned int  initial,
unsigned int  max 
)

Create a new semaphore (removing any stale semaphore with the same name)

Definition at line 408 of file ShmemPlatform.cpp.

◆ open()

bool shmem::NamedSemaphore::open ( const std::string &  name)

Open an existing semaphore.

Definition at line 425 of file ShmemPlatform.cpp.

◆ operator=()

NamedSemaphore & shmem::NamedSemaphore::operator= ( const NamedSemaphore &  )
delete

◆ post()

bool shmem::NamedSemaphore::post ( )

Definition at line 506 of file ShmemPlatform.cpp.

◆ unlink()

void shmem::NamedSemaphore::unlink ( const std::string &  name)
static

Remove the name of the semaphore (no-op on Windows)

Definition at line 446 of file ShmemPlatform.cpp.

◆ wait()

bool shmem::NamedSemaphore::wait ( )

Wait until the semaphore is available.

Definition at line 451 of file ShmemPlatform.cpp.

◆ waitFor()

bool shmem::NamedSemaphore::waitFor ( double  timeout)

Wait at most timeout seconds. Returns true if the semaphore was acquired.

Definition at line 464 of file ShmemPlatform.cpp.


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