#include <exception>
#include <mutex>
-#include <xbt/ex.hpp>
-#include <xbt/log.hpp>
-
+#include "simgrid/Exception.hpp"
+#include "simgrid/barrier.h"
#include "simgrid/s4u/Barrier.hpp"
#include "simgrid/simix.h"
+#include "xbt/log.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_barrier, "S4U barrier");
namespace simgrid {
namespace s4u {
-Barrier::Barrier(unsigned int count) : expected_processes_(count)
+Barrier::Barrier(unsigned int expected_processes) : mutex_(Mutex::create()), cond_(ConditionVariable::create()), expected_processes_(expected_processes)
{
- mutex_ = Mutex::create();
- cond_ = ConditionVariable::create();
}
/**
}
} // namespace s4u
} // namespace simgrid
+
+/* **************************** Public C interface *************************** */
+
+sg_bar_t sg_barrier_init(unsigned int count)
+{
+ return new simgrid::s4u::Barrier(count);
+}
+
+/** @brief Initializes a barrier, with count elements */
+void sg_barrier_destroy(sg_bar_t bar)
+{
+ delete bar;
+}
+
+/** @brief Performs a barrier already initialized */
+int sg_barrier_wait(sg_bar_t bar)
+{
+ return bar->wait();
+}