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"
45class ARCCORE_CONCURRENCY_EXPORT TaskContext
49 explicit TaskContext(
ITask* atask)
70class ARCCORE_CONCURRENCY_EXPORT ITaskFunctor
74 virtual ~ITaskFunctor() =
default;
78 ITaskFunctor(
const ITaskFunctor&) =
default;
79 ITaskFunctor() =
default;
85 virtual ITaskFunctor* clone(
void* buffer,
Integer size) = 0;
95template <
typename InstanceType>
101 typedef void (InstanceType::*FunctorType)();
105 TaskFunctor(InstanceType* instance, FunctorType func)
106 : m_instance(instance)
110 TaskFunctor(
const TaskFunctor& rhs) =
default;
111 TaskFunctor& operator=(
const TaskFunctor& rhs) =
delete;
118 (m_instance->*m_function)();
122 if (
sizeof(*
this) > (
size_t)size)
123 ARCCORE_FATAL(
"INTERNAL: task functor buffer is too small");
129 InstanceType* m_instance;
130 FunctorType m_function;
140template <
typename InstanceType>
141class TaskFunctorWithContext
146 typedef void (InstanceType::*FunctorType)(
const TaskContext& tc);
150 TaskFunctorWithContext(InstanceType* instance, FunctorType func)
152 , m_instance(instance)
162 (m_instance->*m_function)(tc);
166 if (
sizeof(*
this) > (
size_t)size)
167 ARCCORE_FATAL(
"INTERNAL: task functor buffer is too small");
173 InstanceType* m_instance =
nullptr;
174 FunctorType m_function;
185class ARCCORE_CONCURRENCY_EXPORT
ITask
187 friend class TaskFactory;
191 virtual ~ITask() =
default;
Vue constante d'un tableau de type T.
Interface d'un fonctor pour une tâche.
virtual void executeFunctor(const TaskContext &tc)=0
Exécute la méthode associé
Interface d'une tâche concourante.
virtual void launchAndWait()=0
Lance la tâche et bloque jusqu'à ce qu'elle se termine.
virtual void launchAndWait(ConstArrayView< ITask * > tasks)=0
Lance les tâches filles tasks et bloque jusqu'à ce qu'elles se terminent.
Contexte d'éxecution d'une tâche.
ITask * task() const
Tâche courante.
Fonctor pour une tâche prenant un TaskContext en argument.
void executeFunctor(const TaskContext &tc) override
Exécute la méthode associé
Fonctor sans argument pour une tâche.
void executeFunctor(const TaskContext &) override
Exécute la méthode associé
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.