Added Task Scheduler
Former-commit-id: ac37f749ae78f364db3d3edfabc8221802579989
This commit is contained in:
29
include/Nazara/Core/TaskScheduler.hpp
Normal file
29
include/Nazara/Core/TaskScheduler.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_TASKSCHEDULER_HPP
|
||||
#define NAZARA_TASKSCHEDULER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Functor.hpp>
|
||||
|
||||
class NAZARA_API NzTaskScheduler
|
||||
{
|
||||
public:
|
||||
template<typename F> static void AddTask(F function);
|
||||
template<typename F, typename... Args> static void AddTask(F function, Args... args);
|
||||
template<typename C> static void AddTask(void (C::*function)(), C* object);
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
static void WaitForTasks();
|
||||
|
||||
private:
|
||||
static void AddTaskFunctor(NzFunctor* taskFunctor);
|
||||
};
|
||||
|
||||
#include <Nazara/Core/TaskScheduler.inl>
|
||||
|
||||
#endif // NAZARA_TASKSCHEDULER_HPP
|
||||
25
include/Nazara/Core/TaskScheduler.inl
Normal file
25
include/Nazara/Core/TaskScheduler.inl
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename F>
|
||||
void NzTaskScheduler::AddTask(F function)
|
||||
{
|
||||
AddTaskFunctor(new NzFunctorWithoutArgs<F>(function));
|
||||
}
|
||||
|
||||
template<typename F, typename... Args>
|
||||
void NzTaskScheduler::AddTask(F function, Args... args)
|
||||
{
|
||||
AddTaskFunctor(new NzFunctorWithArgs<F, Args...>(function, args...));
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
void NzTaskScheduler::AddTask(void (C::*function)(), C* object)
|
||||
{
|
||||
AddTaskFunctor(new NzMemberWithoutArgs<C>(function, object));
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user