X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2cf13759ba1696d88f5ff86afee5324f30ccdbfc..47950eebfede4e41862022469d15e5e4fe19c7ba:/src/kernel/activity/SemaphoreImpl.cpp diff --git a/src/kernel/activity/SemaphoreImpl.cpp b/src/kernel/activity/SemaphoreImpl.cpp index 9d47f0bce5..2daeba6def 100644 --- a/src/kernel/activity/SemaphoreImpl.cpp +++ b/src/kernel/activity/SemaphoreImpl.cpp @@ -4,7 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/activity/SemaphoreImpl.hpp" -#include "src/simix/smx_synchro_private.hpp" +#include "src/kernel/activity/SynchroRaw.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_semaphore, simix_synchro, "Semaphore kernel-space implementation"); @@ -12,19 +12,17 @@ namespace simgrid { namespace kernel { namespace activity { -void SemaphoreImpl::acquire(smx_actor_t issuer, double timeout) +void SemaphoreImpl::acquire(actor::ActorImpl* issuer, double timeout) { - smx_activity_t synchro = nullptr; - XBT_DEBUG("Wait semaphore %p (timeout:%f)", this, timeout); if (value_ <= 0) { - synchro = SIMIX_synchro_wait(issuer->get_host(), timeout); - synchro->simcalls_.push_front(&issuer->simcall); - issuer->waiting_synchro = synchro; + RawImplPtr synchro = RawImplPtr(new RawImpl()); + synchro->set_host(issuer->get_host()).set_timeout(timeout).start(); + synchro->register_simcall(&issuer->simcall); sleeping_.push_back(*issuer); } else { value_--; - SIMIX_simcall_answer(&issuer->simcall); + issuer->simcall_answer(); } } void SemaphoreImpl::release() @@ -35,7 +33,7 @@ void SemaphoreImpl::release() auto& actor = sleeping_.front(); sleeping_.pop_front(); actor.waiting_synchro = nullptr; - SIMIX_simcall_answer(&actor.simcall); + actor.simcall_answer(); } else { value_++; } @@ -51,7 +49,7 @@ void SemaphoreImpl::release() */ void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem) { - sem->acquire(simcall->issuer, -1); + sem->acquire(simcall->issuer_, -1); } /** @@ -60,5 +58,5 @@ void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem) void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout) { simcall_sem_acquire_timeout__set__result(simcall, 0); // default result, will be set to 1 on timeout - sem->acquire(simcall->issuer, timeout); + sem->acquire(simcall->issuer_, timeout); }