agx::Thread is a representation of an OS specific implementation of a computational thread.
More...
#include <Thread.h>
agx::Thread is a representation of an OS specific implementation of a computational thread.
Threads can execute generic tasks (agx::Task) and jobs (agx::Job).
Definition at line 197 of file Thread.h.
States for the thread.
| Enumerator |
|---|
| THREAD_NEW |
|
| THREAD_RUNNING |
|
| THREAD_DETACHED |
|
| THREAD_DONE |
|
| THREAD_JOINED |
|
| THREAD_CANCELLED |
|
Definition at line 88 of file Thread.h.
| agx::Thread::Thread |
( |
Index |
id | ) |
|
|
protected |
| agx::Thread::Thread |
( |
const Thread & |
| ) |
|
|
protecteddelete |
| virtual agx::Thread::~Thread |
( |
| ) |
|
|
protectedvirtual |
| static void agx::Thread::addTask |
( |
Task * |
task | ) |
|
|
static |
Allocate a storage location that is unique for each thread.
This key will be usable from all threads.
| void agx::BasicThread::cancel |
( |
| ) |
|
|
inherited |
Threads should normally not need to be killed.
Killing a thread can have bad consequences and leak resources. This will forcefully terminate the thread.
The thread should still be joined even after cancel has been called.
| void agx::BasicThread::detach |
( |
| ) |
|
|
inherited |
Detaches the thread to the background.
Will no longer be joinable.
| static void agx::Thread::exportAllTimelines |
( |
| ) |
|
|
static |
| static void agx::Thread::flushLogs |
( |
| ) |
|
|
static |
| static void agx::Thread::flushTimelineLogs |
( |
| ) |
|
|
static |
Deallocate the storage location.
No thread can use 'key' after this method has been called.
Generates a unique universal identifier.
- Returns
- a Unique Universal identifier
| void* agxData::AttributeContainer::getAttribute |
( |
const Attribute * |
attribute | ) |
|
|
inherited |
| const void* agxData::AttributeContainer::getAttribute |
( |
const Attribute * |
attribute | ) |
const |
|
inherited |
template<typename T >
| T & agxData::AttributeContainer::getAttribute |
( |
const ScalarAttributeT< T > * |
attribute | ) |
|
|
inherited |
template<typename T >
| const T & agxData::AttributeContainer::getAttribute |
( |
const ScalarAttributeT< T > * |
attribute | ) |
const |
|
inherited |
| Thread * agx::Thread::getCurrentThread |
( |
| ) |
|
|
static |
| static std::string agx::Thread::getCurrentThreadDescription |
( |
| ) |
|
|
static |
- Returns
- a string describing the current thread. The format is "os, agx" where 'os' is an OS specific identifier (typically a number) and 'agx' is the agx thread id, or null if this is not an agx thread
| static std::thread::native_handle_type agx::BasicThread::getCurrentThreadHandle |
( |
| ) |
|
|
staticinherited |
Return a native_handle for the current executing thread.
| static bool agx::Thread::getEnableJobTimeline |
( |
| ) |
|
|
static |
| Index agx::Thread::getId |
( |
| ) |
const |
| Index agx::Thread::getIndex |
( |
| ) |
const |
Get an index suitable for use when storing per-thread data in e.g.
a Vector. The returned index is the thread ID for regular AGX worker threads and a value larger than the largest thread ID for non-AGX threads that has called registerAsAgxThread.
The value returned may change when the number of AGX threads is changed, and when other threads are registered or unregistered as AGX threads. It is therefor not recommended to store this value for longer than a single time step.
| Thread * agx::Thread::getMainThread |
( |
| ) |
|
|
static |
| Real agx::Thread::getOverheadTime |
( |
| ) |
const |
- Returns
- The overhead time for the thread, including jobpool stalls and job administration.
Definition at line 735 of file Thread.h.
References agx::Timer::getTime().
Return a reference to the mersienne twister used for generating random numbers.
This is local to the thread and can be used safely from the current thread
- Returns
- reference to a mt19937 random generator
Definition at line 730 of file Thread.h.
| Thread * agx::Thread::getThread |
( |
size_t |
id | ) |
|
|
static |
| unsigned int agx::BasicThread::getThreadState |
( |
| ) |
|
|
inlineinherited |
| bool agxData::AttributeContainer::hasAttribute |
( |
const Attribute * |
attribute | ) |
const |
|
inherited |
- Returns
- True if an attribute is active/allocated.
| static void agx::Thread::initThreadSystem |
( |
| ) |
|
|
static |
| bool agx::Thread::isMainThread |
( |
| ) |
|
|
static |
| static bool agx::Thread::isShuttingDown |
( |
| ) |
|
|
static |
| bool agx::BasicThread::join |
( |
| ) |
|
|
inherited |
Joins the thread.
Will block until the thread is done executing.
| bool agx::BasicThread::joinable |
( |
| ) |
|
|
inlineinherited |
| int agx::Thread::log |
( |
const char * |
format, |
|
|
|
... |
|
) |
| |
|
inlinestatic |
| static void agx::Thread::makeCurrentThreadMainThread |
( |
| ) |
|
|
static |
Register current thread as main thread.
NOTE: The old main thread will also think it is the main thread!
Read the thread-local value for the currently executing thread associated with the given key.
Referenced by getCurrentThread().
| static Thread* agx::Thread::registerAsAgxThread |
( |
| ) |
|
|
static |
Register the current thread as an AGX thread.
Necessary to execute agx::Task instances. This is normally handled automatically.
| void agx::Thread::reportSystemJob |
( |
UInt64 |
startTick, |
|
|
UInt64 |
endTick, |
|
|
const char * |
description, |
|
|
const char * |
extraDataTitle = nullptr, |
|
|
agx::Real64 |
extraData = 0.0 |
|
) |
| |
Add an entry to the job duration log.
Intended to be used when the system performs some lengthy operation without using the job system.
This will NOT copy the content of 'description' and 'datatitle', so don't pass pointers to anything that will be deallocated before the next disk writing.
| void agx::Thread::resetOverheadTime |
( |
| ) |
|
Reset the thread overhead time.
| static void agx::Thread::resetStartTick |
( |
| ) |
|
|
static |
| static void agx::Thread::setEnableJobTimeline |
( |
bool |
flag | ) |
|
|
static |
Enable or disable job timeline statistics.
| bool agx::BasicThread::setThreadAffinity |
( |
agx::UInt64 |
cpumask | ) |
|
|
inherited |
Thread Affinity can be used to influence on which logical cores threads are scheduled and allowed to run.
On Windows and Linux, the input is a bitmask where the bits that are set are maps to logical cores.
On OS X, the input value is an affinity tag and threads with the same tag are scheduled so they should share and L2 cache.
Note: If the BasicThread has not yet been launched via start(), then this method will affect the current executing thread.
| static void agx::Thread::shutdown |
( |
| ) |
|
|
static |
Shutdown the threading system.
After this no threads will be available.
| bool agx::Thread::start |
( |
| ) |
|
| void agx::Thread::stop |
( |
| ) |
|
| static void agx::Thread::unregisterAsAgxThread |
( |
| ) |
|
|
static |
Remove agx attributes from current thread.
This is normally handled automatically.
Write to the thread-local location owned by the currently executing thread.
Set the number of threads to use (including the main thread).
- Parameters
-
| numThreads | - The total available number of threads. If 0, then all CPU:s/Cores will be used. |
Shutdown agx.
Must be called before end of main()/unload of dll:s etc.
| bool agx::Thread::immediateLogging |
|
static |
| std::thread agx::BasicThread::m_handle |
|
protectedinherited |
| std::atomic< unsigned int> agx::BasicThread::m_state |
|
protectedinherited |
The documentation for this class was generated from the following file: