Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/oneapi/tbb/null_rw_mutex.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     Copyright (c) 2005-2021 Intel Corporation
0003 
0004     Licensed under the Apache License, Version 2.0 (the "License");
0005     you may not use this file except in compliance with the License.
0006     You may obtain a copy of the License at
0007 
0008         http://www.apache.org/licenses/LICENSE-2.0
0009 
0010     Unless required by applicable law or agreed to in writing, software
0011     distributed under the License is distributed on an "AS IS" BASIS,
0012     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013     See the License for the specific language governing permissions and
0014     limitations under the License.
0015 */
0016 
0017 #ifndef __TBB_null_rw_mutex_H
0018 #define __TBB_null_rw_mutex_H
0019 
0020 #include "detail/_config.h"
0021 #include "detail/_namespace_injection.h"
0022 #include "detail/_mutex_common.h"
0023 
0024 namespace tbb {
0025 namespace detail {
0026 namespace d1 {
0027 
0028 //! A rw mutex which does nothing
0029 /** A null_rw_mutex is a rw mutex that does nothing and simulates successful operation.
0030     @ingroup synchronization */
0031 class null_rw_mutex {
0032 public:
0033     //! Constructors
0034     constexpr null_rw_mutex() noexcept = default;
0035 
0036     //! Destructor
0037     ~null_rw_mutex() = default;
0038 
0039     //! No Copy
0040     null_rw_mutex(const null_rw_mutex&) = delete;
0041     null_rw_mutex& operator=(const null_rw_mutex&) = delete;
0042 
0043     //! Represents acquisition of a mutex.
0044     class scoped_lock {
0045     public:
0046         //! Constructors
0047         constexpr scoped_lock() noexcept = default;
0048         scoped_lock(null_rw_mutex&, bool = true) {}
0049 
0050         //! Destructor
0051         ~scoped_lock() = default;
0052 
0053         //! No Copy
0054         scoped_lock(const scoped_lock&) = delete;
0055         scoped_lock& operator=(const scoped_lock&) = delete;
0056 
0057         void acquire(null_rw_mutex&, bool = true) {}
0058         bool try_acquire(null_rw_mutex&, bool = true) { return true; }
0059         void release() {}
0060         bool upgrade_to_writer() { return true; }
0061         bool downgrade_to_reader() { return true; }
0062 
0063         bool is_writer() const { return true; }
0064     };
0065 
0066     //! Mutex traits
0067     static constexpr bool is_rw_mutex = true;
0068     static constexpr bool is_recursive_mutex = true;
0069     static constexpr bool is_fair_mutex = true;
0070 
0071     void lock() {}
0072     bool try_lock() { return true; }
0073     void unlock() {}
0074     void lock_shared() {}
0075     bool try_lock_shared() { return true; }
0076     void unlock_shared() {}
0077 }; // class null_rw_mutex
0078 
0079 } // namespace d1
0080 } // namespace detail
0081 
0082 inline namespace v1 {
0083 using detail::d1::null_rw_mutex;
0084 } // namespace v1
0085 } // namespace tbb
0086 
0087 #endif /* __TBB_null_rw_mutex_H */