/* A thread pool (C++ version). */
-/* Copyright (c) 2004-2017 The SimGrid Team.
+/* Copyright (c) 2004-2018 The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
public:
Parmap(unsigned num_workers, e_xbt_parmap_mode_t mode);
Parmap(const Parmap&) = delete;
+ Parmap& operator=(const Parmap&) = delete;
~Parmap();
void apply(void (*fun)(T), const std::vector<T>& data);
boost::optional<T> next();
this->fun = fun;
this->data = &data;
this->index = 0;
- this->synchro->master_signal(); // maestro runs futex_wait to wake all the minions (the working threads)
+ this->synchro->master_signal(); // maestro runs futex_wake to wake all the minions (the working threads)
this->work(); // maestro works with its minions
this->synchro->master_wait(); // When there is no more work to do, then maestro waits for the last minion to stop
XBT_CDEBUG(xbt_parmap, "Job done"); // ... and proceeds
#if HAVE_FUTEX_H
res = new FutexSynchro(*this);
#else
- xbt_die("Fute is not available on this OS.");
+ xbt_die("Futex is not available on this OS.");
#endif
break;
case XBT_PARMAP_BUSY_WAIT:
template <typename T> void Parmap<T>::PosixSynchro::master_wait()
{
xbt_os_mutex_acquire(done_mutex);
- if (this->parmap.thread_counter < this->parmap.num_workers) {
+ while (this->parmap.thread_counter < this->parmap.num_workers) {
/* wait for all workers to be ready */
xbt_os_cond_wait(done_cond, done_mutex);
}
{
xbt_os_mutex_acquire(ready_mutex);
/* wait for more work */
- if (this->parmap.work_round != round) {
+ while (this->parmap.work_round != round) {
xbt_os_cond_wait(ready_cond, ready_mutex);
}
xbt_os_mutex_release(ready_mutex);