1 /* Copyright (c) 2018. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include <xbt/log.hpp>
12 #include "simgrid/barrier.h"
13 #include "simgrid/s4u/Barrier.hpp"
14 #include "simgrid/simix.h"
16 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_barrier, "S4U barrier");
21 Barrier::Barrier(unsigned int count) : expected_processes_(count)
23 mutex_ = Mutex::create();
24 cond_ = ConditionVariable::create();
34 XBT_DEBUG("waiting %p %u/%u", this, arrived_processes_, expected_processes_);
35 if (arrived_processes_ == expected_processes_) {
38 arrived_processes_ = 0;
47 } // namespace simgrid
49 /* **************************** Public C interface *************************** */
51 sg_bar_t sg_barrier_init(unsigned int count)
53 return new simgrid::s4u::Barrier(count);
56 /** @brief Initializes a barrier, with count elements */
57 void sg_barrier_destroy(sg_bar_t bar)
62 /** @brief Performs a barrier already initialized */
63 int sg_barrier_wait(sg_bar_t bar)