Import Geant4 11.3.0 source tree
This commit is contained in:
+7
-56
@@ -21,64 +21,15 @@
|
||||
//
|
||||
// Class Description:
|
||||
//
|
||||
// This file defines types and macros used to expose Tasking threading model.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <future>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
namespace PTL
|
||||
{
|
||||
// global thread types
|
||||
using Thread = std::thread;
|
||||
using NativeThread = std::thread::native_handle_type;
|
||||
// std::thread::id does not cast to integer
|
||||
using Pid_t = std::thread::id;
|
||||
|
||||
// Condition
|
||||
using Condition = std::condition_variable;
|
||||
|
||||
// Thread identifier
|
||||
using ThreadId = Thread::id;
|
||||
|
||||
// will be used in the future when migrating threading to task-based style
|
||||
template <typename Tp>
|
||||
using Future = std::future<Tp>;
|
||||
template <typename Tp>
|
||||
using SharedFuture = std::shared_future<Tp>;
|
||||
template <typename Tp>
|
||||
using Promise = std::promise<Tp>;
|
||||
|
||||
// global mutex types
|
||||
using Mutex = std::mutex;
|
||||
using RecursiveMutex = std::recursive_mutex;
|
||||
|
||||
// static functions: get_id(), sleep_for(...), sleep_until(...), yield(),
|
||||
namespace ThisThread
|
||||
{
|
||||
using namespace std::this_thread;
|
||||
}
|
||||
|
||||
// Helper function for getting a unique static mutex for a specific
|
||||
// class or type
|
||||
// Usage example:
|
||||
// a template class "Cache<T>" that required a static
|
||||
// mutex for specific to type T:
|
||||
// AutoLock l(TypeMutex<Cache<T>>());
|
||||
template <typename Tp, typename MutexTp = Mutex, size_t N = 4>
|
||||
MutexTp&
|
||||
TypeMutex(const unsigned int& _n = 0)
|
||||
{
|
||||
static std::array<MutexTp, N> _mutex_array{};
|
||||
return _mutex_array[_n % N];
|
||||
}
|
||||
|
||||
//======================================================================================//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "PTL/Types.hh"
|
||||
|
||||
namespace PTL
|
||||
{
|
||||
namespace Threading
|
||||
{
|
||||
enum
|
||||
@@ -88,6 +39,7 @@ enum
|
||||
WORKER_ID = 0,
|
||||
GENERICTHREAD_ID = -1000
|
||||
};
|
||||
}
|
||||
|
||||
Pid_t
|
||||
GetPidId();
|
||||
@@ -116,5 +68,4 @@ SetPinAffinity(int idx, NativeThread& _t);
|
||||
bool
|
||||
SetThreadPriority(int _v, NativeThread& _t);
|
||||
|
||||
} // namespace Threading
|
||||
} // namespace PTL
|
||||
|
||||
Reference in New Issue
Block a user