Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-30 08:46:18

0001 /*
0002     Copyright (c) 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_detail__mutex_common_H
0018 #define __TBB_detail__mutex_common_H
0019 
0020 #include "_config.h"
0021 #include "_utils.h"
0022 
0023 #if __TBB_CPP20_CONCEPTS_PRESENT
0024 #include <concepts>
0025 
0026 namespace tbb {
0027 namespace detail {
0028 inline namespace d0 {
0029 
0030 template <typename Lock, typename Mutex>
0031 concept mutex_scoped_lock = std::default_initializable<Lock> &&
0032                             std::constructible_from<Lock, Mutex&> &&
0033                             requires( Lock& lock, Mutex& mutex ) {
0034                                 lock.acquire(mutex);
0035                                 { lock.try_acquire(mutex) } -> adaptive_same_as<bool>;
0036                                 lock.release();
0037                             };
0038 
0039 template <typename Lock, typename Mutex>
0040 concept rw_mutex_scoped_lock = mutex_scoped_lock<Lock, Mutex> &&
0041                                std::constructible_from<Lock, Mutex&, bool> &&
0042                                requires( Lock& lock, Mutex& mutex ) {
0043                                    lock.acquire(mutex, false);
0044                                    { lock.try_acquire(mutex, false) } -> adaptive_same_as<bool>;
0045                                    { lock.upgrade_to_writer() } -> adaptive_same_as<bool>;
0046                                    { lock.downgrade_to_reader() } -> adaptive_same_as<bool>;
0047                                };
0048 
0049 template <typename Mutex>
0050 concept scoped_lockable = mutex_scoped_lock<typename Mutex::scoped_lock, Mutex>;
0051 
0052 template <typename Mutex>
0053 concept rw_scoped_lockable = scoped_lockable<Mutex> &&
0054                              rw_mutex_scoped_lock<typename Mutex::scoped_lock, Mutex>;
0055 
0056 } // namespace d0
0057 } // namespace detail
0058 } // namespace tbb
0059 
0060 #endif // __TBB_CPP20_CONCEPTS_PRESENT
0061 #endif // __TBB_detail__mutex_common_H