#pragma once #include #include #include #include "BlackboardStrategy.h" using std::thread; using std::vector; using std::mutex; unsigned gert(); class Blackboard { private: thread* _subthreads[6]; // first fork (2 split) thread* _subsubthreads[6]; // second fork (3 split) BlackboardStrategy* _bbs = nullptr; // BlackboardStrategy instance mutex _bbs_lock; // BlackboardStrategy lock (set/getBest functions) unsigned _fitness[6]; // fitness return values vector _results; // result return values unsigned (BlackboardStrategy::* fitnessStrategies[6])() const = { &BlackboardStrategy::fitnessStrategy1, &BlackboardStrategy::fitnessStrategy2, &BlackboardStrategy::fitnessStrategy3, &BlackboardStrategy::fitnessStrategy4, &BlackboardStrategy::fitnessStrategy5, &BlackboardStrategy::fitnessStrategy6, }; unsigned (BlackboardStrategy::* resultStrategies[6])() const = { &BlackboardStrategy::resultStrategy1, &BlackboardStrategy::resultStrategy2, &BlackboardStrategy::resultStrategy3, &BlackboardStrategy::resultStrategy4, &BlackboardStrategy::resultStrategy5, &BlackboardStrategy::resultStrategy6, }; public: Blackboard(); virtual ~Blackboard(); /** @brief start subthreads for strategy[start_index] until strategy[start_index + length] */ virtual void spawn_subthreads(unsigned start_index, unsigned length); virtual void run(); };