Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::string for Synchro instead of char*
[simgrid.git] / src / simix / Synchro.cpp
index c10c46c..db8d8d6 100644 (file)
@@ -9,7 +9,22 @@ simgrid::simix::Synchro::Synchro() {
   simcalls = xbt_fifo_new();
 }
 
-simgrid::simix::Synchro::~Synchro() {
+simgrid::simix::Synchro::~Synchro()
+{
   xbt_fifo_free(simcalls);
-  xbt_free(name);
+}
+
+void simgrid::simix::Synchro::ref()
+{
+  refcount++;
+}
+void simgrid::simix::Synchro::unref()
+{
+  xbt_assert(refcount > 0,
+      "This synchro has a negative refcount! You can only call test() or wait() once per synchronization.");
+
+  refcount--;
+  if (refcount>0)
+    return;
+  delete this;
 }