Metall v0.30
A persistent memory allocator for data-centric analytics
 
Loading...
Searching...
No Matches
mutex.hpp
Go to the documentation of this file.
1// Copyright 2020 Lawrence Livermore National Security, LLC and other Metall
2// Project Developers. See the top-level COPYRIGHT file for details.
3//
4// SPDX-License-Identifier: (Apache-2.0 OR MIT)
5
6#ifndef METALL_UTILITY_MUTEX_HPP
7#define METALL_UTILITY_MUTEX_HPP
8
9#include <mutex>
10#include <cassert>
11
12namespace metall::utility {
13
16namespace mutex {
17
24template <int num_banks>
25inline std::unique_lock<std::mutex> mutex_lock(const std::size_t index) {
26 static std::mutex mutexes[num_banks];
27 assert(index < num_banks);
28 return std::unique_lock<std::mutex>(mutexes[index]);
29}
30
31} // namespace mutex
32} // namespace metall::utility
33
36
37#endif // METALL_UTILITY_MUTEX_HPP
std::unique_lock< std::mutex > mutex_lock(const std::size_t index)
A utility function that returns a mutex lock allocated as a static object. This is an experimental im...
Definition mutex.hpp:25
Namespace for utility items.