|
|
|||
Warning, file /include/Geant4/PTL/Types.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // 0002 // MIT License 0003 // Copyright (c) 2020 Jonathan R. Madsen 0004 // Permission is hereby granted, free of charge, to any person obtaining a copy 0005 // of this software and associated documentation files (the "Software"), to deal 0006 // in the Software without restriction, including without limitation the rights 0007 // to use, copy, modify, merge, publish, distribute, sublicense, and 0008 // copies of the Software, and to permit persons to whom the Software is 0009 // furnished to do so, subject to the following conditions: 0010 // The above copyright notice and this permission notice shall be included in 0011 // all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 0012 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 0013 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 0014 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 0015 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 0016 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 0017 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 0018 // 0019 // Tasking native types 0020 // 0021 0022 #pragma once 0023 0024 // This file defines types used to expose Tasking threading model. 0025 0026 #pragma once 0027 0028 #include <array> 0029 #include <cstddef> 0030 #include <future> 0031 #include <mutex> 0032 #include <thread> 0033 0034 namespace PTL 0035 { 0036 // global thread types 0037 using Thread = std::thread; 0038 using NativeThread = std::thread::native_handle_type; 0039 // std::thread::id does not cast to integer 0040 using Pid_t = std::thread::id; 0041 0042 // Condition 0043 using Condition = std::condition_variable; 0044 0045 // Thread identifier 0046 using ThreadId = Thread::id; 0047 0048 // will be used in the future when migrating threading to task-based style 0049 template <typename Tp> 0050 using Future = std::future<Tp>; 0051 template <typename Tp> 0052 using SharedFuture = std::shared_future<Tp>; 0053 template <typename Tp> 0054 using Promise = std::promise<Tp>; 0055 0056 // global mutex types 0057 using Mutex = std::mutex; 0058 using RecursiveMutex = std::recursive_mutex; 0059 0060 // static functions: get_id(), sleep_for(...), sleep_until(...), yield(), 0061 namespace ThisThread 0062 { 0063 using namespace std::this_thread; 0064 } 0065 0066 // Helper function for getting a unique static mutex for a specific 0067 // class or type 0068 // Usage example: 0069 // a template class "Cache<T>" that required a static 0070 // mutex for specific to type T: 0071 // AutoLock l(TypeMutex<Cache<T>>()); 0072 template <typename Tp, typename MutexTp = Mutex, size_t N = 4> 0073 MutexTp& 0074 TypeMutex(const unsigned int& _n = 0) 0075 { 0076 static std::array<MutexTp, N> _mutex_array{}; 0077 return _mutex_array[_n % N]; 0078 } 0079 0080 } // namespace PTL
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|