12#ifndef ARCCORE_BASE_TASK_H
13#define ARCCORE_BASE_TASK_H
17#include "arccore/base/RangeFunctor.h"
18#include "arccore/base/FatalErrorException.h"
19#include "arccore/base/ForLoopTraceInfo.h"
20#include "arccore/base/ParallelLoopOptions.h"
21#include "arccore/base/ForLoopRunInfo.h"
23#include "arccore/concurrency/ConcurrencyGlobal.h"
49class ARCCORE_CONCURRENCY_EXPORT TaskContext
53 explicit TaskContext(
ITask* atask)
75class ARCCORE_CONCURRENCY_EXPORT ITaskFunctor
79 virtual ~ITaskFunctor() =
default;
83 ITaskFunctor(
const ITaskFunctor&) =
default;
84 ITaskFunctor() =
default;
90 virtual ITaskFunctor* clone(
void* buffer,
Integer size) = 0;
101template <
typename InstanceType>
107 typedef void (InstanceType::*FunctorType)();
111 TaskFunctor(InstanceType* instance, FunctorType func)
112 : m_instance(instance)
116 TaskFunctor(
const TaskFunctor& rhs) =
default;
117 TaskFunctor& operator=(
const TaskFunctor& rhs) =
delete;
124 (m_instance->*m_function)();
128 if (
sizeof(*
this) > (
size_t)size)
135 InstanceType* m_instance;
136 FunctorType m_function;
147template <
typename InstanceType>
148class TaskFunctorWithContext
153 typedef void (InstanceType::*FunctorType)(
const TaskContext& tc);
157 TaskFunctorWithContext(InstanceType* instance, FunctorType func)
159 , m_instance(instance)
169 (m_instance->*m_function)(tc);
173 if (
sizeof(*
this) > (
size_t)size)
180 InstanceType* m_instance =
nullptr;
181 FunctorType m_function;
193class ARCCORE_CONCURRENCY_EXPORT
ITask
195 friend class TaskFactory;
199 virtual ~ITask() =
default;
#define ARCCORE_FATAL(...)
Macro throwing a FatalErrorException.
Constant view of an array of type T.
Interface for a task functor.
virtual void executeFunctor(const TaskContext &tc)=0
Executes the associated method.
Interface for a concurrent task.
virtual void launchAndWait()=0
Launches the task and blocks until it finishes.
virtual void launchAndWait(ConstArrayView< ITask * > tasks)=0
Launches the child tasks tasks and blocks until they finish.
Execution context of a task.
ITask * task() const
Current task.
Functor for a task taking a TaskContext as an argument.
void executeFunctor(const TaskContext &tc) override
Executes the associated method.
Functor without arguments for a task.
void executeFunctor(const TaskContext &) override
Executes the associated method.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.