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. */
9 #include <xbt/exception.hpp>
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 expected_processes) : mutex_(Mutex::create()), cond_(ConditionVariable::create()), expected_processes_(expected_processes)
32 XBT_DEBUG("waiting %p %u/%u", this, arrived_processes_, expected_processes_);
33 if (arrived_processes_ == expected_processes_) {
36 arrived_processes_ = 0;
45 } // namespace simgrid
47 /* **************************** Public C interface *************************** */
49 sg_bar_t sg_barrier_init(unsigned int count)
51 return new simgrid::s4u::Barrier(count);
54 /** @brief Initializes a barrier, with count elements */
55 void sg_barrier_destroy(sg_bar_t bar)
60 /** @brief Performs a barrier already initialized */
61 int sg_barrier_wait(sg_bar_t bar)