'build/xml/classsimgrid_1_1s4u_1_1Semaphore.xml',
'build/xml/classsimgrid_1_1s4u_1_1VirtualMachine.xml',
'build/xml/actor_8h.xml',
+ 'build/xml/barrier_8h.xml',
+ 'build/xml/cond_8h.xml',
'build/xml/engine_8h.xml',
- 'build/xml/vm_8h.xml'
+ 'build/xml/forward_8h.xml',
+ 'build/xml/host_8h.xml',
+ 'build/xml/link_8h.xml',
+ 'build/xml/mailbox_8h.xml',
+ 'build/xml/msg_8h.xml',
+ 'build/xml/mutex_8h.xml',
+ 'build/xml/semaphore_8h.xml',
+ 'build/xml/vm_8h.xml',
+ 'build/xml/zone_8h.xml'
]
python_modules = [
Synchronization Objects
=======================
+.. _API_s4u_Mutex:
+
+==============
+ Mutex
+==============
+
+.. autodoxyclass:: simgrid::s4u::Mutex
+
+Basic management
+----------------
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Mutex.hpp>
+
+ .. doxygentypedef:: MutexPtr
+
+ .. autodoxymethod:: simgrid::s4u::Mutex::Mutex(kernel::activity::MutexImpl *mutex)
+ .. autodoxymethod:: simgrid::s4u::Mutex::create()
+ .. autodoxymethod:: simgrid::s4u::Mutex::~Mutex()
+
+ .. group-tab:: C
+
+ .. code-block:: C
+
+ #include <simgrid/mutex.h>
+
+ .. doxygentypedef:: sg_mutex_t
+ .. cpp:type:: const s4u_Mutex* const_sg_mutex_t
+
+ Constant pointer to a SimGrid mutex object.
+
+ .. autodoxymethod:: sg_mutex_init()
+ .. autodoxymethod:: sg_mutex_destroy(const_sg_mutex_t mutex)
+
+Locking
+-------
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Mutex::lock()
+ .. autodoxymethod:: simgrid::s4u::Mutex::try_lock()
+ .. autodoxymethod:: simgrid::s4u::Mutex::unlock()
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_mutex_lock(sg_mutex_t mutex)
+ .. autodoxymethod:: sg_mutex_try_lock(sg_mutex_t mutex)
+ .. autodoxymethod:: sg_mutex_unlock(sg_mutex_t mutex)
+
.. _API_s4u_Barrier:
================
.. doxygenfunction:: sg_cond_wait
.. doxygenfunction:: sg_cond_wait_for
-.. _API_s4u_Mutex:
+.. _API_s4u_Semaphore:
-==============
- class Mutex
-==============
+==================
+ Semaphore
+==================
-.. doxygentypedef:: MutexPtr
+.. autodoxyclass:: simgrid::s4u::Semaphore
-.. doxygenclass:: simgrid::s4u::Mutex
- :members:
- :protected-members:
- :undoc-members:
-.. _API_s4u_Semaphore:
+Basic management
+----------------
-==================
- class Semaphore
-==================
+ .. tabs::
-.. doxygentypedef:: SemaphorePtr
+ .. group-tab:: C++
-.. doxygenclass:: simgrid::s4u::Semaphore
- :members:
- :protected-members:
- :undoc-members:
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Semaphore.hpp>
+
+ .. doxygentypedef:: SemaphorePtr
+ .. autodoxymethod:: simgrid::s4u::Semaphore::Semaphore(unsigned int initial_capacity)
+ .. autodoxymethod:: simgrid::s4u::Semaphore::~Semaphore()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::create(unsigned int initial_capacity)
+
+ .. group-tab:: C
+
+ .. code-block:: C
+
+ #include <simgrid/semaphore.h>
+
+ .. doxygentypedef:: sg_sem_t
+ .. cpp:type:: const s4u_Semaphore* const_sg_sem_t
+
+ Constant pointer to a SimGrid semaphore object.
+
+ .. autodoxymethod:: sg_sem_init(int initial_value)
+ .. autodoxymethod:: sg_sem_destroy(const_sg_sem_t sem)
+
+Locking
+-------
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Semaphore::acquire()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::acquire_timeout(double timeout)
+ .. autodoxymethod:: simgrid::s4u::Semaphore::get_capacity()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::release()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::would_block()
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_sem_acquire(sg_sem_t sem)
+ .. autodoxymethod:: sg_sem_acquire_timeout(sg_sem_t sem, double timeout)
+ .. autodoxymethod:: sg_sem_get_capacity(sg_sem_t sem)
+ .. autodoxymethod:: sg_sem_release(sg_sem_t sem)
+ .. autodoxymethod:: sg_sem_would_block(sg_sem_t sem)
Python API Reference
********************
namespace simgrid {
namespace s4u {
-/** @brief A classical mutex, but blocking in the simulation world
- * @ingroup s4u_api
+/** @brief A classical mutex, but blocking in the simulation world.
*
+ * @rst
* It is strictly impossible to use a real mutex, such as
- * <a href="http://en.cppreference.com/w/cpp/thread/mutex">std::mutex</a>
- * or <a href="http://pubs.opengroup.org/onlinepubs/007908775/xsh/pthread_mutex_lock.html">pthread_mutex_t</a>,
+ * `std::mutex <http://en.cppreference.com/w/cpp/thread/mutex>`_
+ * or `pthread_mutex_t <http://pubs.opengroup.org/onlinepubs/007908775/xsh/pthread_mutex_lock.html>`_,
* because it would block the whole simulation.
- * Instead, you should use the present class, that is a drop-in replacement of
- * <a href="http://en.cppreference.com/w/cpp/thread/mutex">std::mutex</a>.
+ * Instead, you should use the present class, that is a drop-in replacement of these mechanisms.
*
- * @beginrst
- * As for any S4U object, Mutexes are using the :ref:`RAII idiom <s4u_raii>` for memory management.
+ * An example is available in Section :ref:`s4u_ex_IPC`.
+ *
+ * As for any S4U object, you can use the :ref:`RAII idiom <s4u_raii>` for memory management of Mutexes.
* Use :cpp:func:`create() <simgrid::s4u::Mutex::create()>` to get a :cpp:type:`simgrid::s4u::MutexPtr` to a newly
* created mutex, and only manipulate :cpp:type:`simgrid::s4u::MutexPtr`.
* @endrst
- *
*/
class XBT_PUBLIC Mutex {
friend ConditionVariable;
friend XBT_PUBLIC void intrusive_ptr_release(const Mutex* mutex);
public:
-#ifndef DOXYGEN
explicit Mutex(kernel::activity::MutexImpl* mutex) : pimpl_(mutex) {}
~Mutex();
+#ifndef DOXYGEN
Mutex(Mutex const&) = delete; // No copy constructor; Use MutexPtr instead
Mutex& operator=(Mutex const&) = delete; // No direct assignment either. Use MutexPtr instead
#endif
namespace s4u {
/** @brief A classical semaphore, but blocking in the simulation world
- * @ingroup s4u_api
*
+ * @rst
* It is strictly impossible to use a real semaphore, such as
- * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_init.html">sem_init</a>,
+ * `sem_init <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_init.html>`_,
* 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 @ref s4u_raii "RAII idiom" for memory management.
- * Use #create() to get a simgrid::s4u::SemaphorePtr to a newly created semaphore
- * and only manipulate simgrid::s4u::SemaphorePtr.
+ * An example is available in Section :ref:`s4u_ex_IPC`.
+ *
+ * As for any S4U object, you can use the :ref:`RAII idiom <s4u_raii>` for memory management of semaphores.
+ * Use :cpp:func:`create() <simgrid::s4u::Mutex::create()>` to get a :cpp:type:`simgrid::s4u::SemaphorePtr` to a newly
+ * created semaphore, that will get automatically freed when the variable goes out of scope.
+ * @endrst
*
*/
class XBT_PUBLIC Semaphore {
explicit Semaphore(unsigned int initial_capacity);
~Semaphore();
- // No copy:
- /** You cannot create a new semaphore by copying an existing one. Use SemaphorePtr instead */
- Semaphore(Semaphore const&) = delete;
- /** You cannot create a new semaphore by value assignment either. Use SemaphorePtr instead */
- Semaphore& operator=(Semaphore const&) = delete;
+#ifndef DOXYGEN
+ Semaphore(Semaphore const&) = delete; // No copy constructor. Use SemaphorePtr instead
+ Semaphore& operator=(Semaphore const&) = delete; // No direct assignment either. Use SemaphorePtr instead
+#endif
/** Constructs a new semaphore */
static SemaphorePtr create(unsigned int initial_capacity);