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"
21#include "arccore/concurrency/ParallelLoopOptions.h"
22#include "arccore/concurrency/ForLoopRunInfo.h"
46class ARCCORE_CONCURRENCY_EXPORT TaskContext
50 explicit TaskContext(
ITask* atask)
71class ARCCORE_CONCURRENCY_EXPORT ITaskFunctor
75 virtual ~ITaskFunctor() =
default;
79 ITaskFunctor(
const ITaskFunctor&) =
default;
80 ITaskFunctor() =
default;
86 virtual ITaskFunctor* clone(
void* buffer,
Integer size) = 0;
96template <
typename InstanceType>
102 typedef void (InstanceType::*FunctorType)();
106 TaskFunctor(InstanceType* instance, FunctorType func)
107 : m_instance(instance)
111 TaskFunctor(
const TaskFunctor& rhs) =
default;
112 TaskFunctor& operator=(
const TaskFunctor& rhs) =
delete;
119 (m_instance->*m_function)();
123 if (
sizeof(*
this) > (
size_t)size)
124 ARCCORE_FATAL(
"INTERNAL: task functor buffer is too small");
130 InstanceType* m_instance;
131 FunctorType m_function;
141template <
typename InstanceType>
142class TaskFunctorWithContext
147 typedef void (InstanceType::*FunctorType)(
const TaskContext& tc);
151 TaskFunctorWithContext(InstanceType* instance, FunctorType func)
153 , m_instance(instance)
163 (m_instance->*m_function)(tc);
167 if (
sizeof(*
this) > (
size_t)size)
168 ARCCORE_FATAL(
"INTERNAL: task functor buffer is too small");
174 InstanceType* m_instance =
nullptr;
175 FunctorType m_function;
186class ARCCORE_CONCURRENCY_EXPORT
ITask
188 friend class TaskFactory;
192 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.