Loading...
Searching...
No Matches
CoroutineScheduler.hpp
Go to the documentation of this file.
#pragma once
#include <mutex>
#include <SFML/System/Clock.hpp>
#include <SFML/System/Time.hpp>
#include <EASTL/functional.h>
#include <EASTL/vector.h>
namespace mce::core {
class CoroutineScheduler {
public:
using Callback = eastl::function<sf::Time()>;
CoroutineScheduler() = default;
~CoroutineScheduler();
struct Task {
Callback callback;
sf::Time interval;
sf::Clock clock;
};
void addTask(Callback cb);
void processTasks();
private:
std::mutex tasksMutex;
eastl::vector<Task> vecTasks;
sf::Clock clock;
};
}
mce::core::CoroutineScheduler::CoroutineScheduler
CoroutineScheduler()=default
Default constructor.
mce::core::CoroutineScheduler::Callback
eastl::function< sf::Time()> Callback
Callback type invoked by scheduled tasks.
Definition CoroutineScheduler.hpp:39
mce::core::CoroutineScheduler::processTasks
void processTasks()
Process all scheduled tasks.
Definition CoroutineScheduler.cpp:20
mce::core::CoroutineScheduler::addTask
void addTask(Callback cb)
Add a task to the scheduler.
Definition CoroutineScheduler.cpp:10
mce::core::CoroutineScheduler::Task
Represents a single scheduled task.
Definition CoroutineScheduler.hpp:53
mce::core::CoroutineScheduler::Task::interval
sf::Time interval
Definition CoroutineScheduler.hpp:55
mce::core::CoroutineScheduler::Task::clock
sf::Clock clock
Definition CoroutineScheduler.hpp:56
mce::core::CoroutineScheduler::Task::callback
Callback callback
Definition CoroutineScheduler.hpp:54