1 #ifndef COMUTEX_H_INCLUDED 2 #define COMUTEX_H_INCLUDED 4 #include <dash/Exception.h> 6 #include <dash/Mutex.h> 48 using _storage_type = std::vector<dash::Mutex>;
51 using iterator =
typename _storage_type::iterator;
52 using const_iterator =
typename _storage_type::const_iterator;
53 using reference =
typename _storage_type::reference;
54 using size_type =
typename _storage_type::size_type;
68 iterator begin() noexcept {
69 return _mutexes.begin();
72 const_iterator begin()
const noexcept {
73 return _mutexes.begin();
76 iterator end() noexcept {
77 return _mutexes.end();
80 const_iterator end()
const noexcept {
81 return _mutexes.end();
84 size_type size()
const noexcept {
85 return _mutexes.size();
95 _mutexes.reserve(team.
size());
96 for(decltype(team.
size()) i = 0; i<team.
size(); ++i){
97 _mutexes.emplace_back(team);
100 DASH_ASSERT_MSG((team == *_team),
101 "Comutex was initialized with a different team");
103 _is_initialized =
true;
106 inline Team & team() {
114 DASH_ASSERT_MSG(_is_initialized,
"Comutex is not initialized");
115 return _mutexes.at(unit);
122 return this->
operator()(static_cast<int>(unit));
126 _storage_type _mutexes;
128 bool _is_initialized =
false;
This class is a simple memory pool which holds allocates elements of size ValueType.
bool is_initialized()
Check whether DASH has been initialized already.
Comutex(Team &team=dash::Team::All())
Constructor to setup and initialize an Comutex.
size_t size() const
The number of units in this team.
A Team instance specifies a subset of all available units.
void initialize(Team &team)
initializeds the mutexes.
reference operator()(const int &unit)
Operator to select mutex at given unit.
reference operator()(const team_unit_t &unit)
Operator to select mutex at given unit.
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
static Team & All()
The invariant Team instance containing all available units.