-
首页
-
C4D R23.110 C++ SDK
详细描述
Enumerations
|
enum
|
JOBGROUPFLAGS
{
DEFAULT
,
ENQUEUEING_THREAD_WAITS
,
FINALIZE_ON_WAIT
,
THREAD_AFFINITY
}
|
enum
|
STATICJOBGROUPFLAGS
{
DEFAULT
,
ENQUEUEING_THREAD_WAITS
,
THREAD_AFFINITY
}
|
enum
|
STATICJOBARRAYFLAGS
{
DEFAULT
,
INITIALIZE_LATER
}
|
enum
|
JOBQUEUETYPE
{
MAINTHREAD
,
NONE
,
LOWESTPRIORITY
,
LOWPRIORITY
,
NORMALPRIORITY
,
SERVICEIO
,
THREADLESS
}
|
enum
|
JOBQUEUEMODE
{
DEFAULT
,
SPIN_ON_IDLE
,
SLEEP_ON_IDLE
,
DETACH_THREADS
,
PSEUDO_THREADS
}
|
enum
|
PARALLELFORFLAGS
{
INITTHREADED_FINALIZETHREADED
,
INITTHREADED_FINALIZESYNC
,
INITSYNC_FINALIZETHREADED
,
INITSYNC_FINALIZESYNC
,
NOINIT_NOFINALIZE
,
INITTHREADEDWITHSYNC_FINALIZESYNC
}
|
函数
|
template<typename FN >
|
auto
|
ExecuteOnMainThread
(FN &&fn,
Bool
wait=true) -> decltype(fn())
|
JOBOPTIONFLAGS
|
GetJobOptions
() const
|
const
Char
*
|
GetName
() const
|
|
JobInterface
(const JobInterfaceJumpTablePOD &jmpTable)
|
|
~JobInterface
()
|
|
JobInterface
(
JobInterface
&&
src
)
|
JobInterface
&
|
operator=
(
JobInterface
&&
src
)
|
Bool
|
Wait
(
TimeValue
timeout=
TIMEVALUE_INFINITE
,
WAITMODE
mode=
WAITMODE::DEFAULT
) const
|
Result
< void >
|
GetResult
(
TimeValue
timeout=
TIMEVALUE_INFINITE
,
WAITMODE
mode=
WAITMODE::DEFAULT
) const
|
Result
< void >
|
MoveResult
(
TimeValue
timeout=
TIMEVALUE_INFINITE
,
WAITMODE
mode=
WAITMODE::DEFAULT
)
|
void
|
取消
()
|
Bool
|
IsCancelled
() const
|
void
|
CancelAndWait
(
WAITMODE
mode=
WAITMODE::DEFAULT
)
|
JobInterface
*
|
Enqueue
(
JobQueueInterface
*queue=
JOBQUEUE_CURRENT
)
|
Result
< void >
|
AddSubJob
(
JobInterface
*subJob)
|
template<typename JOB >
|
Result
< void >
|
AddSubJob
(
ResultMemT
< JOB * > subJob)
|
template<typename JOBREF >
|
Result
< void >
|
AddSubJob
(
ResultMemT
< JOBREF > &&subJob)
|
template<typename GROUP >
|
Result
< void >
|
AddSubGroup
(GROUP *subGroup)
|
template<typename GROUP >
|
Result
< void >
|
AddSubGroup
(
ResultMemT
< GROUP * > subGroup)
|
template<typename GROUP >
|
Result
< void >
|
AddSubGroup
(
ResultMemT
< GROUP > subGroup)
|
JobGroupInterface
*
|
GetJobGroup
() const
|
ObservableFinishedBase
<
JobInterface
>
|
ObservableFinished
()
|
ObservableCancelledBase
<
JobInterface
>
|
ObservableCancelled
()
|
static
Int
|
GetCurrentWorkerThreadIndex
()
|
static
Int
|
GetCurrentThreadCount
()
|
static
Bool
|
IsCurrentJobCancelled
(const
JobInterface
*optionalJob=nullptr)
|
static
JobStatusInterface
*
|
GetCurrentJob
()
|
String
|
ToString
(const
FormatStatement
*formatStatement=nullptr) const
|
|
MAXON_DISALLOW_COPY_AND_ASSIGN
(
JobInterface
)
|
template<typename IMPLEMENTATION >
|
static IMPLEMENTATION &
|
GetWorker
(const
JobInterface
*job)
|
template<typename IMPLEMENTATION >
|
static void *
|
DestructWorker
(const
JobInterface
*self)
|
template<typename IMPLEMENTATION >
|
static const
ErrorInterface
*
|
RunWorker
(const
JobInterface
*job)
|
template<typename T >
|
static const JobDependencyGroupInterface *
|
GetWorkerDependencyGroupImpl
(const
JobInterface
*job, std::false_type *)
|
template<typename T >
|
static const JobDependencyGroupInterface *
|
GetWorkerDependencyGroupImpl
(const
JobInterface
*job, std::true_type *)
|
template<typename IMPLEMENTATION >
|
static const JobDependencyGroupInterface *
|
GetWorkerDependencyGroup
(const
JobInterface
*job)
|
template<typename IMPLEMENTATION >
|
static void *
|
GetWorkerOptions
(const
JobInterface
*self,
Int
selector, void *param)
|
static CoreJobGroup &
|
GetCoreJobGroup
(
JobGroupInterface
*group)
|
Bool
|
IsCancelled
() const
|
JobGroupInterface
*
|
GetJobGroup
() const
|
|
MAXON_DEFAULT_REFERENCE_CONSTRUCTORS
(
JobStatusRef
,
Ptr
)
|
MAXON_IMPLICIT
|
JobStatusRef
(const
Ptr
&
src
)
|
MAXON_IMPLICIT
|
JobStatusRef
(
Ptr
&&
src
)
|
MAXON_IMPLICIT
|
JobStatusRef
(
JobInterface
*
src
)
|
Bool
|
IsCancelled
() const
|
JobGroupInterface
*
|
GetJobGroup
() const
|
static const
JobStatusRef
&
|
NullValue
()
|
String
|
ToString
(const
FormatStatement
*formatStatement=nullptr) const
|
JobStatusInterface
*
|
operator->
() const
|
Result
< RESULTVALUETYPE >
|
GetResult
(
TimeValue
timeout=
TIMEVALUE_INFINITE
,
WAITMODE
mode=
WAITMODE::DEFAULT
) const
|
Result
< RESULTVALUETYPE >
|
MoveResult
(
TimeValue
timeout=
TIMEVALUE_INFINITE
,
WAITMODE
mode=
WAITMODE::DEFAULT
)
|
ResultOk
< void >
|
SetResult
(RESULTVALUETYPE &&value)
|
template<typename FN , typename... ARGS>
|
Result
< void >
|
Invoke
(FN &&obj, ARGS &&... args)
|
Result
< RESULTVALUETYPE >
|
GetResult
(
TimeValue
timeout=
TIMEVALUE_INFINITE
,
WAITMODE
mode=
WAITMODE::DEFAULT
) const
|
Result
< RESULTVALUETYPE >
|
MoveResult
(
TimeValue
timeout=
TIMEVALUE_INFINITE
,
WAITMODE
mode=
WAITMODE::DEFAULT
)
|
template<typename R >
|
Result
< void >
|
SetResult
(R &&value)
|
template<typename FN , typename... ARGS>
|
Result
< void >
|
Invoke
(FN &&obj, ARGS &&... args)
|
template<typename R >
|
Result
< void >
|
SetResult
(R &&resultOnly)
|
template<typename FN , typename... ARGS>
|
Result
< void >
|
Invoke
(FN &&obj, ARGS &&... args)
|
ResultOk
< void >
|
SetResult
()
|
template<typename FN , typename... ARGS>
|
Result
< void >
|
Invoke
(FN &&obj, ARGS &&... args)
|
template<typename... ARGS>
|
static
ResultMemT
<
JobResultRef
< RESULTVALUETYPE > >
|
创建
(ARGS &&... args)
|
|
MAXON_DISALLOW_COPY_AND_ASSIGN
(
JobInterfaceTemplate
)
|
|
MAXON_DATATYPE
(
JobRef
, "net.maxon.datatype.job")
|
enum
maxon::JOBGROUPFLAGS
|
MAXON_ENUM_FLAGS
(
JOBGROUPFLAGS
)
|
enum
maxon::STATICJOBGROUPFLAGS
|
MAXON_ENUM_FLAGS
(
STATICJOBGROUPFLAGS
)
|
enum
maxon::STATICJOBARRAYFLAGS
|
MAXON_ENUM_FLAGS
(
STATICJOBARRAYFLAGS
)
|
enum
maxon::JOBQUEUETYPE
|
MAXON_ENUM_LIST
(
JOBQUEUETYPE
)
|
enum
maxon::JOBQUEUEMODE
|
MAXON_ENUM_LIST
(
JOBQUEUEMODE
)
|
enum
maxon::PARALLELFORFLAGS
|
MAXON_ENUM_FLAGS
(
PARALLELFORFLAGS
)
|
template<typename... ARGS>
|
Result
< void >
|
ParallelInvoke
(
Bool
parallel, ARGS &&... args)
|
|
MAXON_DATATYPE
(
ThreadRef
, "net.maxon.datatype.threadref")
|
Macro Definition Documentation
◆
DISABLE_IF_LOOP_TYPE_IS_INT
#define DISABLE_IF_LOOP_TYPE_IS_INT
|
(
|
|
TYPE,
|
|
|
|
...
|
|
)
|
|
|
Typedef Documentation
◆
Ptr
◆
ThreadRef
Reference to a thread (
ThreadInterface
).
Enumeration Type Documentation
◆
JOBGROUPFLAGS
Flags for enqueue options of a JobGroup.
Enumerator
|
DEFAULT
|
Default case.
|
ENQUEUEING_THREAD_WAITS
|
The enqueuing thread waits until the group has finished and might be used to execute jobs.
|
FINALIZE_ON_WAIT
|
After Enqueue() further Add()s can be made which start the jobs ASAP. A following call to Wait() or GetResult() finalizes the group (no more jobs can be added). Can be useful if there is a lot of setup work before a job can be added.
|
THREAD_AFFINITY
|
On Enqueue() each jobs is permanently assigned to a worker thread. This blocks load balancing and is therefore slower and only useful for special cases. If a group with thread affinity had more jobs than the queue had threads its jobs must not have dependencies or wait calls. Only supported for queues where thread affinity has been enabled.
|
◆
STATICJOBGROUPFLAGS
Flags describing the ownership of a StaticJobGroup. You don't have to bother using anything other than DEFAULT.
Enumerator
|
DEFAULT
|
Safe default case.
|
ENQUEUEING_THREAD_WAITS
|
The enqueuing thread waits until the group has finished and might be used to execute jobs.
|
THREAD_AFFINITY
|
On Enqueue() each jobs is permanently assigned to a worker thread. This blocks load balancing and therefore slower and only useful for special cases.
|
◆
STATICJOBARRAYFLAGS
Initialization options for the
StaticJobArray
.
Enumerator
|
DEFAULT
|
Default behaviour:
Array
is empty.
|
INITIALIZE_LATER
|
Array
consists of as many uninitialized elements as it has capacity. The caller will construct them later on (before it is added to the group).
|
◆
JOBQUEUETYPE
Type of job queue.
Enumerator
|
MAINTHREAD
|
Jobs are executed on the main thread whenever the event loop can spare some time: there is only one queue of this type: use GetMainThreadQueue() to access it.
|
NONE
|
Jobs are not enqueued but executed in the current context.
|
LOWESTPRIORITY
|
Use lowest priority threads (worker threads have lowest priority and will not idle when waiting for new jobs or waiting for a group to finish).
|
LOWPRIORITY
|
Use low priority threads.
|
NORMALPRIORITY
|
Use normal priority threads (You should rarely have to create a queue with normal priority. Most of the time low priority is sufficient: This makes sure that you don't interfere with really important tasks and if available you still get all cpu power).
|
SERVICEIO
|
Queue
is used for IO and priority is adapted accordingly. Spinning on idle is not allowed.
|
THREADLESS
|
|
◆
JOBQUEUEMODE
Options for the job queue.
Enumerator
|
DEFAULT
|
Use default settings for the queue.
|
SPIN_ON_IDLE
|
When there are no jobs threads will be spinning for a short moment before they go to sleep (low latency and highest performance but might unnecessary steals cycles from other threads).
|
SLEEP_ON_IDLE
|
When there are no jobs threads will immediately go to sleep (results in higher latency).
|
DETACH_THREADS
|
When there are no jobs the threads will immediately go to sleep and make themselves available to other queues (results in higher latency but less memory/resource usage).
|
PSEUDO_THREADS
|
The workers behave like ordinary threads (JOBQUEUE_CURRENT points to the default queue and the threads don't have a worker thread index).
|
◆
PARALLELFORFLAGS
Flags controlling the threading of the init and finalize section of
ParallelFor
. The default case is INITTHREADED_FINALIZESYNC. Each worker thread will independently call the init section for its part of the loop and then execute the loop body. The init section of a thread might be executed after any another thread has almost executed the whole loop -
there's no guarantee that all init sections have finished before the loop body is entered, you might even have worker threads that don't run the init, loop and finalize section because another thread has already done the whole work
. After the loop has finished for each init section the corresponding finalize will be called synchronously one after another. There might be cases where you must make sure that the init section for all worker threads has finished before the loop is executed, for example because you also must initialize some global variables for each worker thread that will be utilized by nested ParallelFors or other sub-jobs. Depending on your needs you might specify INITSYNC_FINALIZETHREADED, INITSYNC_FINALIZESYNC or INITTHREADEDWITHSYNC_FINALIZESYNC. Please note that INITTHREADEDWITHSYNC_FINALIZESYNC is slower than INITTHREADED_FINALIZESYNC because of the additional synchronization after the init phase.
Enumerator
|
INITTHREADED_FINALIZETHREADED
|
Init() and Finalize() calls are threaded.
|
INITTHREADED_FINALIZESYNC
|
Init() is called threaded, Finalize() is called synchronously (default case).
|
INITSYNC_FINALIZETHREADED
|
Init() is called synchronously, Finalize() is called threaded.
|
INITSYNC_FINALIZESYNC
|
Init() and Finalize() are called synchronously.
|
NOINIT_NOFINALIZE
|
no call to Init() or Finalize().
|
INITTHREADEDWITHSYNC_FINALIZESYNC
|
Init() is called threaded but the parallel loop body won't start until Init() has finished for all threads, Finalize() is called synchronously.
|
Function Documentation
◆
ExecuteOnMainThread()
auto ExecuteOnMainThread
|
(
|
FN &&
|
fn
,
|
|
|
Bool
|
wait
|
|
)
|
|
-> decltype(fn())
|
Executes a lambda on the main thread and returns its result (if any). If the current thread is the main thread the lambda is executed directly. Otherwise a job will be enqueued and the function waits until it has finished. If the job does not return any values and can be executed asynchronously you might specify false as wait parameter. The job is always guaranteed to be executed and this method will only return an error if the lambda does.
-
参数
-
[in]
|
fn
|
Lambda object with the code to be executed.
|
[in]
|
wait
|
True if the caller should wait until the lambda has been executed. False is only permitted for lambdas without return values.
|
-
返回
-
Return value of the lambda.
◆
GetJobOptions()
JOBOPTIONFLAGS GetJobOptions
|
(
|
|
)
|
const
|
-
注意
-
This method must not block. It can be called from any thread and this might happen concurrently.
◆
GetName()
const
Char
* GetName
|
(
|
|
)
|
const
|
-
注意
-
This method must not block. It can be called from any thread and this might happen concurrently.
◆
JobInterface()
[1/2]
Initializes the
JobInterface
including the jump table to the implementation methods.
-
参数
-
[in]
|
jmpTable
|
Jump table of the implementation class.
|
◆
~JobInterface()
◆
JobInterface()
[2/2]
Move constructor is just for use with
BaseArray
(
JobGroupInterface::Add()
)
◆
operator=()
Move assignment operator is just for use with
BaseArray
(
JobGroupInterface::Add()
).
◆
Wait()
Waits until this job has been executed. As long as a job hasn't been started it is considered not to have finished yet. Once it has run this will return immediately.
Wait()
might execute other jobs in the current queue until the one you are waiting for has finished or is timed out. Therefore you must never lock a shared resource another job might use as well and then wait. For one this could dead-lock and conceptually this would result in single-threaded performance.
If you call
Wait()
from within an enqueued job
you must have enqueued what you are waiting for
. Otherwise
Wait()
will immediately return false because this would lead to a deadlock. The same applies if a job tries to wait for itself.
Instead of waiting for a job to start some action after it has finished you can subscribe to
ObservableFinished()
. This cannot dead-lock, is more efficient and can even be used to run the observer in a different queue. For example you can run a job and register an observer for it that will run on the main thread's queue and updates the UI. THREADSAFE.
-
参数
-
[in]
|
timeout
|
Maximum wait interval (or TIMEVALUE_INFINITE for no time-out).
|
[in]
|
mode
|
WAITMODE::DEFAULT
by default.
WAITMODE::RETURN_ON_CANCEL
means that
Wait()
will return if the caller has been cancelled even if the condition has not been set yet.
|
-
返回
-
True if successful, false if you try to wait inside an enqueued job.
◆
GetResult()
[1/3]
Waits until this job has been executed and returns the result. THREADSAFE.
-
参数
-
[in]
|
timeout
|
Maximum wait interval (or TIMEVALUE_INFINITE for no time-out).
|
[in]
|
mode
|
WAITMODE::DEFAULT
by default.
WAITMODE::RETURN_ON_CANCEL
means that
Wait()
will return if the caller has been cancelled even if the condition has not been set yet.
|
-
返回
-
OK on success.
◆
MoveResult()
[1/3]
Waits until this job has been executed and returns the result via std::move.
-
注意
-
You may only use
MoveResult()
if you can ensure that nobody else will ask for the result of the job. THREADSAFE.
-
参数
-
[in]
|
timeout
|
Maximum wait interval (or TIMEVALUE_INFINITE for no time-out).
|
[in]
|
mode
|
WAITMODE::DEFAULT
by default.
WAITMODE::RETURN_ON_CANCEL
means that
Wait()
will return if the caller has been cancelled even if the condition has not been set yet.
|
-
返回
-
OK on success.
◆
Cancel()
Asks the job to cancel execution. If the job is a part of a group the whole group will be cancelled. Cancellation of a job does not affect its finish observers. The call will not wait for the job to cancel. THREADSAFE.
◆
IsCancelled()
[1/3]
Bool
IsCancelled
|
(
|
|
)
|
const
|
Checks if the job should stop. THREADSAFE.
-
返回
-
True if the job has been asked to cancel.
◆
CancelAndWait()
Asks the job to cancel execution and waits until it has finished. If the job is a part of a group the whole group will be cancelled. Cancellation of a job does not affect its finish observers. THREADSAFE.
-
参数
-
◆
Enqueue()
Enqueues this job (will add a reference and remove it when the object is no longer needed). THREADSAFE.
-
参数
-
[in]
|
queue
|
The queue, use JOBQUEUE_CURRENT for the current queue.
|
-
返回
-
Always this pointer (for concatenation).
◆
AddSubJob()
[1/3]
Adds a job to this job's group (see JobGroup). The caller must belong to a group. THREADSAFE.
-
参数
-
[in]
|
subJob
|
Job (nullptr will return error).
|
-
返回
-
OK on success.
◆
AddSubJob()
[2/3]
Adds a job to this job's group (see JobGroup). The caller must belong to a group. THREADSAFE.
-
参数
-
[in]
|
subJob
|
Job (nullptr will return error).
|
-
返回
-
OK on success.
◆
AddSubJob()
[3/3]
Adds a job to this job's group (see JobGroup). The caller must belong to a group. THREADSAFE.
-
参数
-
[in]
|
subJob
|
Job (encapsulated in a
ResultMemT
directly returned from creation).
|
-
返回
-
OK on success.
◆
AddSubGroup()
[1/3]
Result
<void> AddSubGroup
|
(
|
GROUP *
|
subGroup
|
)
|
|
Adds a subgroup to this job's group. The caller must belong to a group. THREADSAFE.
-
参数
-
[in]
|
subGroup
|
Job group (nullptr will return error).
|
-
返回
-
OK on success.
◆
AddSubGroup()
[2/3]
Adds a subgroup to this job's group. The caller must belong to a group. THREADSAFE.
-
参数
-
[in]
|
subGroup
|
Job group (encapsulated in a
ResultMemT
directly returned from creation).
|
-
返回
-
OK on success.
◆
AddSubGroup()
[3/3]
Adds a subgroup to this job's group. The caller must belong to a group. THREADSAFE.
-
参数
-
[in]
|
subGroup
|
Job group (encapsulated in a
ResultMemT
directly returned from creation).
|
-
返回
-
OK on success.
◆
GetJobGroup()
[1/3]
Returns the group a job belongs to. THREADSAFE.
-
返回
-
JobGroup this job belongs to or nullptr if it's not part of a group.
◆
ObservableFinished()
ObservableFinished is an observable that is triggered after this job has been executed. THREADSAFE.
-
返回
-
Custom observable.
◆
ObservableCancelled()
ObservableCancelled is an observable that is triggered when this job is cancelled. THREADSAFE.
-
返回
-
Custom observable.
◆
GetCurrentWorkerThreadIndex()
static
Int
GetCurrentWorkerThreadIndex
|
(
|
|
)
|
|
|
static
|
Returns the index of the internal worker thread which is running this job. If the job is not running as part of a worker thread 0 is returned to make sure you can safely use this as index to an array with thread local data. THREADSAFE.
-
返回
-
Index between 0 and the number of threads used for the queue - 1.
◆
GetCurrentThreadCount()
static
Int
GetCurrentThreadCount
|
(
|
|
)
|
|
|
static
|
Returns the number of worker threads for the current job context. This might be different from the actual CPU core or thread count. THREADSAFE.
-
返回
-
Number of worker threads, guaranteed to be > 0.
◆
IsCurrentJobCancelled()
static
Bool
IsCurrentJobCancelled
|
(
|
const
JobInterface
*
|
optionalJob
=
nullptr
|
)
|
|
|
static
|
Checks if the currently running job (or thread) should stop. Works for jobs and threads. THREADSAFE.
-
参数
-
[in]
|
optionalJob
|
Optional job which should also be checked for cancellation.
|
-
返回
-
True if the job has been asked to cancel.
◆
GetCurrentJob()
Returns a pointer to the currently running job which can be used to check if it's cancelled. Works for jobs and threads.
-
返回
-
Currently running job. Can be nullptr if called from an alien thread.
◆
ToString()
[1/2]
Returns a readable string of the content.
-
参数
-
[in]
|
formatStatement
|
Nullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
|
-
返回
-
The converted result.
◆
MAXON_DISALLOW_COPY_AND_ASSIGN()
[1/2]
◆
GetWorker()
static IMPLEMENTATION& GetWorker
|
(
|
const
JobInterface
*
|
job
|
)
|
|
|
static
private
|
◆
DestructWorker()
◆
RunWorker()
◆
GetWorkerDependencyGroupImpl()
[1/2]
static const JobDependencyGroupInterface* GetWorkerDependencyGroupImpl
|
(
|
const
JobInterface
*
|
job
,
|
|
|
std::false_type *
|
|
|
)
|
|
|
|
static
private
|
◆
GetWorkerDependencyGroupImpl()
[2/2]
static const JobDependencyGroupInterface* GetWorkerDependencyGroupImpl
|
(
|
const
JobInterface
*
|
job
,
|
|
|
std::true_type *
|
|
|
)
|
|
|
|
static
private
|
◆
GetWorkerDependencyGroup()
static const JobDependencyGroupInterface* GetWorkerDependencyGroup
|
(
|
const
JobInterface
*
|
job
|
)
|
|
|
static
private
|
◆
GetWorkerOptions()
static void* GetWorkerOptions
|
(
|
const
JobInterface
*
|
self
,
|
|
|
Int
|
selector
,
|
|
|
void *
|
param
|
|
)
|
|
|
|
static
private
|
◆
GetCoreJobGroup()
◆
IsCancelled()
[2/3]
Bool
IsCancelled
|
(
|
|
)
|
const
|
Checks if the job should stop. THREADSAFE.
-
返回
-
True if the job has been asked to cancel.
◆
GetJobGroup()
[2/3]
Returns the group a job belongs to. THREADSAFE.
-
返回
-
JobGroup this job belongs to or nullptr if it's not part of a group.
◆
MAXON_DEFAULT_REFERENCE_CONSTRUCTORS()
◆
JobStatusRef()
[1/3]
◆
JobStatusRef()
[2/3]
◆
JobStatusRef()
[3/3]
◆
IsCancelled()
[3/3]
Bool
IsCancelled
|
(
|
|
)
|
const
|
Checks if the job should stop. Will return true for a null reference. THREADSAFE.
-
返回
-
True if the job has been asked to cancel.
◆
GetJobGroup()
[3/3]
Returns the group a job belongs to. THREADSAFE.
-
返回
-
JobGroup this job belongs to or nullptr if it's not part of a group.
◆
NullValue()
Returns a null value of the
JobRef
(见
nullvalue.h
for more details).
-
返回
-
A null value of the
JobRef
.
◆
ToString()
[2/2]
Returns a readable string of the content.
-
参数
-
[in]
|
formatStatement
|
Nullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
|
-
返回
-
The converted result.
◆
operator->()
◆
GetResult()
[2/3]
Waits until this job has been executed and returns the result. THREADSAFE.
-
参数
-
[in]
|
timeout
|
Maximum wait interval (or TIMEVALUE_INFINITE for no time-out).
|
[in]
|
mode
|
WAITMODE::DEFAULT
by default.
WAITMODE::RETURN_ON_CANCEL
means that
Wait()
will return if the caller has been cancelled even if the condition has not been set yet.
|
-
返回
-
Result
value on success.
◆
MoveResult()
[2/3]
Waits until this job has been executed and returns the result via std::move.
-
注意
-
You may only use
MoveResult()
if you can ensure that nobody else will ask for the result of the job. THREADSAFE.
-
参数
-
[in]
|
timeout
|
Maximum wait interval (or TIMEVALUE_INFINITE for no time-out).
|
[in]
|
mode
|
WAITMODE::DEFAULT
by default.
WAITMODE::RETURN_ON_CANCEL
means that
Wait()
will return if the caller has been cancelled even if the condition has not been set yet.
|
-
返回
-
Result
value on success.
◆
SetResult()
[1/4]
ResultOk
<void> SetResult
|
(
|
RESULTVALUETYPE &&
|
value
|
)
|
|
|
protected
|
Sets the result value returned by
GetResult()
.
-
返回
-
OK on success.
◆
Invoke()
[1/4]
Result
<void> Invoke
|
(
|
FN &&
|
obj
,
|
|
|
ARGS &&...
|
args
|
|
)
|
|
|
|
protected
|
◆
GetResult()
[3/3]
Waits until this job has been executed and returns the result. THREADSAFE.
-
参数
-
[in]
|
timeout
|
Maximum wait interval (or TIMEVALUE_INFINITE for no time-out).
|
[in]
|
mode
|
WAITMODE::DEFAULT
by default.
WAITMODE::RETURN_ON_CANCEL
means that
Wait()
will return if the caller has been cancelled even if the condition has not been set yet.
|
-
返回
-
Result
value on success.
◆
MoveResult()
[3/3]
Waits until this job has been executed and returns the result via std::move.
-
注意
-
You may only use
MoveResult()
if you can ensure that nobody else will ask for the result of the job. THREADSAFE.
-
参数
-
[in]
|
timeout
|
Maximum wait interval (or TIMEVALUE_INFINITE for no time-out).
|
[in]
|
mode
|
WAITMODE::DEFAULT
by default.
WAITMODE::RETURN_ON_CANCEL
means that
Wait()
will return if the caller has been cancelled even if the condition has not been set yet.
|
-
返回
-
Result
value on success.
◆
SetResult()
[2/4]
Result
<void> SetResult
|
(
|
R &&
|
value
|
)
|
|
|
protected
|
Sets the result value returned by
GetResult()
.
-
返回
-
OK on success.
◆
Invoke()
[2/4]
Result
<void> Invoke
|
(
|
FN &&
|
obj
,
|
|
|
ARGS &&...
|
args
|
|
)
|
|
|
|
protected
|
◆
SetResult()
[3/4]
Result
<void> SetResult
|
(
|
R &&
|
resultOnly
|
)
|
|
|
protected
|
Sets the result value returned by
GetResult()
(in this specialisation the
Result<void>
is just forwarded).
-
返回
-
OK on success.
◆
Invoke()
[3/4]
Result
<void> Invoke
|
(
|
FN &&
|
obj
,
|
|
|
ARGS &&...
|
args
|
|
)
|
|
|
|
protected
|
◆
SetResult()
[4/4]
Sets the result value returned by
GetResult()
(in this specialisiation just a dummy because it's void).
-
返回
-
OK on success.
◆
Invoke()
[4/4]
Result
<void> Invoke
|
(
|
FN &&
|
obj
,
|
|
|
ARGS &&...
|
args
|
|
)
|
|
|
|
protected
|
◆
Create()
Creates the job.
-
参数
-
[in]
|
args
|
Arguments for the construcor.
|
-
Template Parameters
-
-
返回
-
JobRef
on success, OutOfMemoryerror on failure.
◆
MAXON_DISALLOW_COPY_AND_ASSIGN()
[2/2]
◆
MAXON_DATATYPE()
[1/2]
maxon::MAXON_DATATYPE
|
(
|
JobRef
|
,
|
|
|
"net.maxon.datatype.job"
|
|
|
)
|
|
|
◆
MAXON_ENUM_FLAGS()
[1/4]
◆
MAXON_ENUM_FLAGS()
[2/4]
◆
MAXON_ENUM_FLAGS()
[3/4]
◆
MAXON_ENUM_LIST()
[1/2]
◆
MAXON_ENUM_LIST()
[2/2]
◆
MAXON_ENUM_FLAGS()
[4/4]
◆
ParallelInvoke()
Result
<void> maxon::ParallelInvoke
|
(
|
Bool
|
parallel
,
|
|
|
ARGS &&...
|
args
|
|
)
|
|
|
Executes multiple functions in parallel and waits until they have finished. The parallel flag should be used for recursive code and set to false once the work item size is so small it wouldn't make sense to parallelize it any further. Please note that using
ParallelInvoke()
to parallelize a recursive algorithm is handy but will never perform as good as using a parallelized non-recursive algorithm because of the required synchronization at each recursion level. Execution of the parallel code is guaranteed - even under low memory conditions. If the lambdas do not return
Result<void>
the routine will return OK.
-
参数
-
[in]
|
parallel
|
True for parallel execution, false if amount of work has become very small.
|
[in]
|
args
|
Callable objects, usually lambdas.
|
-
Template Parameters
-
-
返回
-
OK on success. Will only return an error if a lambda returns one via
Result<void>
. Please note that you'll receive an
AggregatedError
here that contains the errors created in the lambda and not the errors directly.
◆
MAXON_DATATYPE()
[2/2]
maxon::MAXON_DATATYPE
|
(
|
ThreadRef
|
,
|
|
|
"net.maxon.datatype.threadref"
|
|
|
)
|
|
|
Variable Documentation
◆
_result
[1/2]
RESULTVALUETYPE _result
|
private
|
◆
_result
[2/2]
Result
<RESULTVALUETYPE> _result
|
|
private
|
◆
JOBQUEUE_USEMAXIMUMTHREADS
const
Int
JOBQUEUE_USEMAXIMUMTHREADS
static
|
|
◆
JOBQUEUE_CURRENT
const JobQueueInterface::Current JOBQUEUE_CURRENT
|
static
|
Equivalent to calling GetDestinationQueue(), you just save a function call.
◆
JOBQUEUE_NONE
const JobQueueInterface::None JOBQUEUE_NONE
|
static
|
For notifications and timer jobs: Executes them immediately on the current thread.
◆
MAXON_ENUM_LIST_CLASS
◆
PARALLELFOR_DEFAULTGRANULARITY
const
Int
PARALLELFOR_DEFAULTGRANULARITY
static
|
|
◆
PARALLELFOR_MINIMUMGRANULARITY
const
Int
PARALLELFOR_MINIMUMGRANULARITY
static
|
|
◆
PARALLELFOR_USEMAXIMUMTHREADS
const
Int
PARALLELFOR_USEMAXIMUMTHREADS
static
|
|
◆
PARALLELFOR_DISABLETHREADING
const
Int
PARALLELFOR_DISABLETHREADING
static
|
|
◆
PARALLELFOR_MAXIMUMDEPTH
const
Int
PARALLELFOR_MAXIMUMDEPTH
static
|
|
◆
g_trackSpinlocks
Friends
◆
StrongRefHandler
[1/2]
◆
ObservableFinishedBase
friend struct ObservableFinishedBase
|
friend
|
◆
ObservableCancelledBase
friend struct ObservableCancelledBase
|
friend
|
◆
JobStatusInterface
◆
JobGroupInterface
◆
StaticJobGroupInterface
◆
TimerInterface
◆
StrongRefHandler
[2/2]
◆
ExecuteOnMainThread
auto ExecuteOnMainThread
|
(
|
FN &&
|
fn
,
|
|
|
Bool
|
wait
|
|
)
|
|
-> decltype(fn())
|
|
friend
|
Executes a lambda on the main thread and returns its result (if any). If the current thread is the main thread the lambda is executed directly. Otherwise a job will be enqueued and the function waits until it has finished. If the job does not return any values and can be executed asynchronously you might specify false as wait parameter. The job is always guaranteed to be executed and this method will only return an error if the lambda does.
-
参数
-
[in]
|
fn
|
Lambda object with the code to be executed.
|
[in]
|
wait
|
True if the caller should wait until the lambda has been executed. False is only permitted for lambdas without return values.
|
-
返回
-
Return value of the lambda.