SimGrid  3.21
Versatile Simulation of Distributed Systems
simgrid::s4u::Semaphore Class Reference

Detailed Description

A classical semaphore, but blocking in the simulation world

It is strictly impossible to use a real semaphore, such as sem_init, because it would block the whole simulation.

Instead, you should use the present class, that offers a very similar interface.

As for any S4U object, Semaphores are using the RAII idiom for memory management. Use create() to get a simgrid::s4u::SemaphorePtr to a newly created semaphore and only manipulate simgrid::s4u::SemaphorePtr.

#include <Semaphore.hpp>

Public Member Functions

 Semaphore (Semaphore const &)=delete
 You cannot create a new semaphore by copying an existing one. More...
 
Semaphoreoperator= (Semaphore const &)=delete
 You cannot create a new semaphore by value assignment either. More...
 
void acquire ()
 
void release ()
 

Static Public Member Functions

static SemaphorePtr create (unsigned int initial_capacity)
 Constructs a new semaphore. More...
 

Friends

void intrusive_ptr_add_ref (Semaphore *sem)
 
void intrusive_ptr_release (Semaphore *sem)
 

Constructor & Destructor Documentation

◆ Semaphore()

simgrid::s4u::Semaphore::Semaphore ( Semaphore const &  )
delete

You cannot create a new semaphore by copying an existing one.

Use SemaphorePtr instead

Member Function Documentation

◆ operator=()

Semaphore& simgrid::s4u::Semaphore::operator= ( Semaphore const &  )
delete

You cannot create a new semaphore by value assignment either.

Use SemaphorePtr instead

◆ create()

static SemaphorePtr simgrid::s4u::Semaphore::create ( unsigned int  initial_capacity)
static

Constructs a new semaphore.

◆ acquire()

void simgrid::s4u::Semaphore::acquire ( )

◆ release()

void simgrid::s4u::Semaphore::release ( )

Friends And Related Function Documentation

◆ intrusive_ptr_add_ref

void intrusive_ptr_add_ref ( Semaphore sem)
friend

◆ intrusive_ptr_release

void intrusive_ptr_release ( Semaphore sem)
friend

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