Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / simix / smx_synchro.cpp
index b8eff39..442695e 100644 (file)
@@ -8,12 +8,12 @@
 #include "smx_private.h"
 #include "xbt/log.h"
 
+#include "src/simix/SynchroRaw.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_synchro, simix,
                                 "SIMIX Synchronization (mutex, semaphores and conditions)");
 
 static smx_synchro_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout);
-static void SIMIX_synchro_finish(smx_synchro_t synchro);
 static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout,
                              smx_process_t issuer, smx_simcall_t simcall);
 static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer,
@@ -25,13 +25,10 @@ static smx_synchro_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout)
 {
   XBT_IN("(%p, %f)",smx_host,timeout);
 
-  smx_synchro_t sync;
-  sync = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator);
-  sync->type = SIMIX_SYNC_SYNCHRO;
-  sync->name = xbt_strdup("synchro");
-  sync->synchro.sleep = surf_host_sleep(smx_host, timeout);
-
-  sync->synchro.sleep->setData(sync);
+  simgrid::simix::Raw *sync = new simgrid::simix::Raw();
+  sync->name = nullptr;
+  sync->sleep = surf_host_sleep(smx_host, timeout);
+  sync->sleep->setData(sync);
   XBT_OUT();
   return sync;
 }
@@ -69,29 +66,14 @@ void SIMIX_synchro_stop_waiting(smx_process_t process, smx_simcall_t simcall)
 
 void SIMIX_synchro_destroy(smx_synchro_t synchro)
 {
-  XBT_IN("(%p)",synchro);
   XBT_DEBUG("Destroying synchro %p", synchro);
-  xbt_assert(synchro->type == SIMIX_SYNC_SYNCHRO);
-  synchro->synchro.sleep->unref();
-  xbt_free(synchro->name);
-  xbt_mallocator_release(simix_global->synchro_mallocator, synchro);
-  XBT_OUT();
-}
+  simgrid::simix::Raw *raw = static_cast<simgrid::simix::Raw*>(synchro);
 
-void SIMIX_post_synchro(smx_synchro_t synchro)
-{
-  XBT_IN("(%p)",synchro);
-  xbt_assert(synchro->type == SIMIX_SYNC_SYNCHRO);
-  if (synchro->synchro.sleep->getState() == SURF_ACTION_FAILED)
-    synchro->state = SIMIX_FAILED;
-  else if(synchro->synchro.sleep->getState() == SURF_ACTION_DONE)
-    synchro->state = SIMIX_SRC_TIMEOUT;
-
-  SIMIX_synchro_finish(synchro);  
-  XBT_OUT();
+  raw->sleep->unref();
+  delete raw;
 }
 
-static void SIMIX_synchro_finish(smx_synchro_t synchro)
+void SIMIX_synchro_finish(smx_synchro_t synchro)
 {
   XBT_IN("(%p)",synchro);
   smx_simcall_t simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls);