Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/oneapi/tbb/null_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_mutex_H
0018 #define __TBB_null_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 mutex which does nothing
0029 /** A null_mutex does no operation and simulates success.
0030     @ingroup synchronization */
0031 class null_mutex {
0032 public:
0033     //! Constructors
0034     constexpr null_mutex() noexcept = default;
0035 
0036     //! Destructor
0037     ~null_mutex() = default;
0038 
0039     //! No Copy
0040     null_mutex(const null_mutex&) = delete;
0041     null_mutex& operator=(const null_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_mutex&) {}
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_mutex&) {}
0058         bool try_acquire(null_mutex&) { return true; }
0059         void release() {}
0060     };
0061 
0062     //! Mutex traits
0063     static constexpr bool is_rw_mutex = false;
0064     static constexpr bool is_recursive_mutex = true;
0065     static constexpr bool is_fair_mutex = true;
0066 
0067     void lock() {}
0068     bool try_lock() { return true; }
0069     void unlock() {}
0070 }; // class null_mutex
0071 
0072 } // namespace d1
0073 } // namespace detail
0074 
0075 inline namespace v1 {
0076 using detail::d1::null_mutex;
0077 } // namespace v1
0078 } // namespace tbb
0079 
0080 #endif /* __TBB_null_mutex_H */