xenium
acquire_guard.hpp
1 //
2 // Copyright (c) 2018-2020 Manuel Pöter.
3 // Licensed under the MIT License. See LICENSE file in the project root for full license information.
4 //
5 
6 #ifndef XENIUM_ACQUIRE_GUARD_HPP
7 #define XENIUM_ACQUIRE_GUARD_HPP
8 
9 #include <atomic>
10 
11 namespace xenium {
12 
20 template <typename ConcurrentPtr>
21 auto acquire_guard(ConcurrentPtr& p, std::memory_order order = std::memory_order_seq_cst) {
22  typename ConcurrentPtr::guard_ptr guard;
23  guard.acquire(p, order);
24  return guard;
25 }
26 
27 } // namespace xenium
28 
29 #endif