Branch data Line data Source code
1 : : // ----------------- BEGIN LICENSE BLOCK --------------------------------- 2 : : // 3 : : // Copyright (C) 2022 Intel Corporation 4 : : // 5 : : // SPDX-License-Identifier: LGPL-2.1-only 6 : : // 7 : : // ----------------- END LICENSE BLOCK ----------------------------------- 8 : : /** 9 : : * @file 10 : : */ 11 : : 12 : : #pragma once 13 : : 14 : : #include <mutex> 15 : : #include <shared_mutex> 16 : : 17 : : /*! 18 : : * @brief namespace rss 19 : : */ 20 : : namespace ad { 21 : : /*! 22 : : * @brief namespace rss 23 : : */ 24 : : namespace rss { 25 : : /*! 26 : : * @brief namespace map 27 : : */ 28 : : namespace core { 29 : : 30 : : class shared_lock_guard 31 : : { 32 : : public: 33 : 20 : shared_lock_guard(std::shared_timed_mutex &lock) 34 : 20 : : mLock(lock) 35 : : { 36 : 20 : mLock.lock_shared(); 37 : 20 : } 38 : 20 : ~shared_lock_guard() 39 : : { 40 : 20 : mLock.unlock_shared(); 41 : 20 : } 42 : : 43 : : private: 44 : : std::shared_timed_mutex &mLock; 45 : : }; 46 : : 47 : : } // namespace core 48 : : } // namespace rss 49 : : } // namespace ad