1 // Copyright (C) 2016 John Biddiscombe
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 
6 #ifndef HPX_PARCELSET_POLICIES_VERBS_RDMA_LOCKS_HPP
7 #define HPX_PARCELSET_POLICIES_VERBS_RDMA_LOCKS_HPP
8 
9 #include <hpx/config/parcelport_defines.hpp>
10 //
11 #include <plugins/parcelport/parcelport_logging.hpp>
12 #include <mutex>
13 
14 namespace hpx {
15 namespace parcelset {
16 namespace policies {
17 namespace verbs
18 {
19 #ifdef HPX_PARCELPORT_VERBS_DEBUG_LOCKS
20     template<typename Mutex>
21     struct scoped_lock: std::lock_guard<Mutex>
22     {
scoped_lockhpx::parcelset::policies::verbs::scoped_lock23         scoped_lock(Mutex &m) : std::lock_guard<Mutex>(m)
24         {
25             LOG_DEVEL_MSG("Creating scoped_lock RAII");
26         }
27 
~scoped_lockhpx::parcelset::policies::verbs::scoped_lock28         ~scoped_lock()
29         {
30             LOG_DEVEL_MSG("Destroying scoped_lock RAII");
31         }
32     };
33 
34     template<typename Mutex>
35     struct unique_lock: std::unique_lock<Mutex>
36     {
unique_lockhpx::parcelset::policies::verbs::unique_lock37         unique_lock(Mutex &m) : std::unique_lock<Mutex>(m)
38         {
39             LOG_DEVEL_MSG("Creating unique_lock RAII");
40         }
41 
unique_lockhpx::parcelset::policies::verbs::unique_lock42         unique_lock(Mutex& m, std::try_to_lock_t t) : std::unique_lock<Mutex>(m, t)
43         {
44             LOG_DEVEL_MSG("Creating unique_lock try_to_lock_t RAII");
45         }
46 
~unique_lockhpx::parcelset::policies::verbs::unique_lock47         ~unique_lock()
48         {
49             LOG_DEVEL_MSG("Destroying unique_lock RAII");
50         }
51     };
52 #else
53     template<typename Mutex>
54     using scoped_lock = std::lock_guard<Mutex>;
55 
56     template<typename Mutex>
57     using unique_lock = std::unique_lock<Mutex>;
58 #endif
59 }}}}
60 
61 #endif
62 
63