20 #ifndef HEDGEHOG_DEFAULT_SCHEDULER_H 21 #define HEDGEHOG_DEFAULT_SCHEDULER_H 26 #include "abstract_scheduler.h" 32 std::unique_ptr<std::vector<std::thread>>
34 std::unique_ptr<std::vector<std::shared_ptr<core::CoreNode>>>
40 this->
threads_ = std::make_unique<std::vector<std::thread>>();
41 this->
innerGraphs_ = std::make_unique<std::vector<std::shared_ptr<core::CoreNode>>>();
46 [[nodiscard]] std::unique_ptr<AbstractScheduler>
create()
const override {
47 return std::make_unique<DefaultScheduler>();
55 void spawnThreads(std::vector<std::shared_ptr<core::CoreNode>> &insideCores)
override {
57 for (
auto &core : insideCores) {
59 if (core->type() != core::NodeType::Graph) {
69 std::for_each(
threads_->begin(),
threads_->end(), [](std::thread &t) { t.join(); });
70 for (std::shared_ptr<core::CoreNode> &innerGraph : *(this->
innerGraphs_)) { innerGraph->joinThreads(); }
75 #endif //HEDGEHOG_DEFAULT_SCHEDULER_H std::unique_ptr< std::vector< std::thread > > threads_
List of threads spawned.
void joinAll() override
Wait for all inside nodes to join and join the threads of all inside graphs.
~DefaultScheduler() override=default
Default destructor.
Default scheduler for Hedgehog graph.
std::unique_ptr< AbstractScheduler > create() const override
Definition of virtual constructor.
Abstract Hedgehog Scheduler interface, define per graph how the threads are bound to the nodes...
virtual void run()
Run method, main execution.
void spawnThreads(std::vector< std::shared_ptr< core::CoreNode >> &insideCores) override
Spawn the threads for all graph's inside node.
DefaultScheduler()
Default constructor.
std::unique_ptr< std::vector< std::shared_ptr< core::CoreNode > > > innerGraphs_
List of inner graphs, all graphs could have it owns AbstractScheduler.