About
Additionally to creating jobs (Jobs Manual) it is possible to create custom threads. Such custom threads can run in parallel to the main thread to perform various operations.
Custom Threads
A custom thread is defined by implementing a custom class based on maxon::ThreadInterfaceTemplate:
{
public:
~CalculatePiThread()
{
_totalPointCount = 0;
_insidePointCount = 0;
}
{
{
++_insidePointCount;
++_totalPointCount;
}
}
{
if (_totalPointCount == 0)
return pi;
}
private:
};
Definition: apibasemath.h:54
Definition: lib_math.h:19
FLOAT Get01()
Returns the next random value in the range of [0..1].
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:202
char Char
signed 8 bit character
Definition: apibase.h:198
Float64 Float
Definition: apibase.h:211
return OK
Definition: apibase.h:2735
#define MAXON_UNLIKELY(...)
Definition: compilerdetection.h:427
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
const Char * GetName() const
Definition: job.h:189
Bool IsCancelled() const
Checks if the job should stop. THREADSAFE.
Definition: job.h:307
void Cancel()
Asks the job to cancel execution. If the job is a part of a group the whole group will be cancelled....
Definition: job.h:297
A vector consisting of two components X and Y.
Definition: vec2.h:16
constexpr T GetSquaredLength() const
Returns the squared length of the vector.
Definition: vec2.h:430
Usage
An instance of a custom thread is typically stored as a global static variable:
Custom threads are based on maxon::ThreadInterface and maxon::JobInterface. maxon::ThreadInterface functions are:
if (!g_calculatePiThread)
{
}
else
{
g_calculatePiThread = nullptr;
}
void CancelAndWait(WAITMODE mode=WAITMODE::DEFAULT)
Definition: thread.h:316
static auto Create(ARGS &&... args)
Definition: apibase.h:2818
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:170
#define iferr_return
Definition: resultbase.h:1524
Further static utility functions are:
Further Reading