SOFA API  1c8b807d
Open source framework for multi-physics simuation
sofa::simulation::TaskScheduler Class Referenceabstract

#include <TaskScheduler.h>

Inheritance diagram for sofa::simulation::TaskScheduler:

Detailed Description

Base class for a task scheduler

The API allows to:

  • initialize the scheduler with a number of dedicated threads
  • add a task to the scheduler
  • wait until all tasks are done etc.

Public Member Functions

virtual ~TaskScheduler ()=default
 
virtual void init (const unsigned int nbThread=0)=0
 
virtual void stop (void)=0
 
virtual unsigned int getThreadCount (void) const =0
 
virtual const chargetCurrentThreadName ()=0
 
virtual int getCurrentThreadType ()=0
 
virtual bool addTask (Task *task)=0
 
virtual bool addTask (Task::Status &status, const std::function< void()> &task)
 
virtual void workUntilDone (Task::Status *status)=0
 
virtual Task::AllocatorgetTaskAllocator ()=0
 

Static Public Member Functions

static unsigned GetHardwareThreadsCount ()
 

Friends

class Task
 

Constructor details

◆ ~TaskScheduler()

virtual sofa::simulation::TaskScheduler::~TaskScheduler ( )
virtualdefault

Function details

◆ addTask() [1/2]

virtual bool sofa::simulation::TaskScheduler::addTask ( Task task)
pure virtual

◆ addTask() [2/2]

bool sofa::simulation::TaskScheduler::addTask ( Task::Status status,
const std::function< void()> &  task 
)
virtual

◆ getCurrentThreadName()

virtual const char* sofa::simulation::TaskScheduler::getCurrentThreadName ( )
pure virtual

◆ getCurrentThreadType()

virtual int sofa::simulation::TaskScheduler::getCurrentThreadType ( )
pure virtual

◆ GetHardwareThreadsCount()

unsigned sofa::simulation::TaskScheduler::GetHardwareThreadsCount ( )
static

Assuming 2 concurrent threads by CPU core, return the number of CPU core on the system

◆ getTaskAllocator()

virtual Task::Allocator* sofa::simulation::TaskScheduler::getTaskAllocator ( )
pure virtual

◆ getThreadCount()

virtual unsigned int sofa::simulation::TaskScheduler::getThreadCount ( void  ) const
pure virtual

◆ init()

virtual void sofa::simulation::TaskScheduler::init ( const unsigned int  nbThread = 0)
pure virtual

◆ stop()

virtual void sofa::simulation::TaskScheduler::stop ( void  )
pure virtual

◆ workUntilDone()

virtual void sofa::simulation::TaskScheduler::workUntilDone ( Task::Status status)
pure virtual

Related details

◆ Task

friend class Task
friend