Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Add refcount to Process
[simgrid.git] / src / simix / Synchro.cpp
index c10c46c..e64a060 100644 (file)
@@ -5,11 +5,26 @@
 
 #include "src/simix/Synchro.h"
 
-simgrid::simix::Synchro::Synchro() {
-  simcalls = xbt_fifo_new();
+simgrid::simix::Synchro::Synchro()
+{
 }
 
-simgrid::simix::Synchro::~Synchro() {
-  xbt_fifo_free(simcalls);
-  xbt_free(name);
+simgrid::simix::Synchro::~Synchro()
+{
+}
+
+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;
 }