X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/24abd31b4d1ca03baeb72fc1c7fc031ea7b11a88..956cb23848021301bcb4c20fd31675f65e4348e5:/src/simix/smx_synchro_private.hpp diff --git a/src/simix/smx_synchro_private.hpp b/src/simix/smx_synchro_private.hpp index 5846b045f1..0ba8d40431 100644 --- a/src/simix/smx_synchro_private.hpp +++ b/src/simix/smx_synchro_private.hpp @@ -7,60 +7,23 @@ #define SIMIX_SYNCHRO_PRIVATE_H #include "simgrid/s4u/ConditionVariable.hpp" -#include "xbt/swag.h" +#include "src/simix/ActorImpl.hpp" +#include -namespace simgrid { -namespace simix { - -class XBT_PUBLIC() MutexImpl { -public: - MutexImpl(); - ~MutexImpl(); - MutexImpl(MutexImpl const&) = delete; - MutexImpl& operator=(MutexImpl const&) = delete; - - void lock(smx_actor_t issuer); - bool try_lock(smx_actor_t issuer); - void unlock(smx_actor_t issuer); - - bool locked = false; - smx_actor_t owner = nullptr; - // List of sleeping processes: - xbt_swag_t sleeping = nullptr; - - // boost::intrusive_ptr support: - friend void intrusive_ptr_add_ref(MutexImpl* mutex) - { - XBT_ATTRIB_UNUSED auto previous = mutex->refcount_.fetch_add(1); - xbt_assert(previous != 0); - } - friend void intrusive_ptr_release(MutexImpl* mutex) - { - if (mutex->refcount_.fetch_sub(1) == 1) - delete mutex; - } - - simgrid::s4u::Mutex& mutex() { return mutex_; } - -private: - std::atomic_int_fast32_t refcount_{1}; - simgrid::s4u::Mutex mutex_; -}; -} -} +smx_activity_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout); struct s_smx_cond_t { s_smx_cond_t() : cond_(this) {} std::atomic_int_fast32_t refcount_{1}; smx_mutex_t mutex = nullptr; - xbt_swag_t sleeping = nullptr; /* list of sleeping process */ + simgrid::simix::SynchroList sleeping; /* list of sleeping processes */ simgrid::s4u::ConditionVariable cond_; }; struct s_smx_sem_t { unsigned int value; - xbt_swag_t sleeping; /* list of sleeping process */ + simgrid::simix::SynchroList sleeping; /* list of sleeping processes */ }; XBT_PRIVATE void SIMIX_post_synchro(smx_activity_t synchro);