src: applied clang-format
This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
#include "Blackboard.h"
|
||||
|
||||
Blackboard::Blackboard()
|
||||
{
|
||||
}
|
||||
Blackboard::Blackboard() {}
|
||||
|
||||
Blackboard::Blackboard(std::shared_ptr<Blackboard> parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
}
|
||||
Blackboard::Blackboard(std::shared_ptr<Blackboard> parent): m_parent(parent) {}
|
||||
|
||||
bool Blackboard::exists(const std::string& key)
|
||||
{
|
||||
|
||||
@@ -11,22 +11,15 @@
|
||||
|
||||
struct BlackboardItemBase
|
||||
{
|
||||
virtual ~BlackboardItemBase()
|
||||
{
|
||||
}
|
||||
virtual ~BlackboardItemBase() {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct BlackboardItem: public BlackboardItemBase
|
||||
{
|
||||
BlackboardItem(const T &v)
|
||||
: value(v)
|
||||
{
|
||||
}
|
||||
BlackboardItem(const T& v): value(v) {}
|
||||
|
||||
virtual ~BlackboardItem()
|
||||
{
|
||||
}
|
||||
virtual ~BlackboardItem() {}
|
||||
|
||||
T value;
|
||||
};
|
||||
@@ -78,7 +71,8 @@ bool Blackboard::get(const std::string& key, T& value)
|
||||
ItemMap::const_iterator it = m_items.find(key);
|
||||
if (it != m_items.end())
|
||||
{
|
||||
if (std::shared_ptr<BlackboardItem<T>> item = std::dynamic_pointer_cast<BlackboardItem<T>>(it->second))
|
||||
if (std::shared_ptr<BlackboardItem<T>> item = std::dynamic_pointer_cast<BlackboardItem<T>>(
|
||||
it->second))
|
||||
{
|
||||
value = item->value;
|
||||
return true;
|
||||
@@ -101,7 +95,8 @@ bool Blackboard::update(const std::string& key, std::function<T(const T&)> updat
|
||||
ItemMap::const_iterator it = m_items.find(key);
|
||||
if (it != m_items.end())
|
||||
{
|
||||
if (std::shared_ptr<BlackboardItem<T>> item = std::dynamic_pointer_cast<BlackboardItem<T>>(it->second))
|
||||
if (std::shared_ptr<BlackboardItem<T>> item = std::dynamic_pointer_cast<BlackboardItem<T>>(
|
||||
it->second))
|
||||
{
|
||||
item->value = updater(item->value);
|
||||
return true;
|
||||
@@ -112,4 +107,4 @@ bool Blackboard::update(const std::string& key, std::function<T(const T&)> updat
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // BLACKBOARD_H
|
||||
#endif // BLACKBOARD_H
|
||||
|
||||
@@ -49,6 +49,4 @@ void Task::reset(std::shared_ptr<Blackboard> blackboard)
|
||||
m_exitCalled = false;
|
||||
}
|
||||
|
||||
void Task::terminate()
|
||||
{
|
||||
}
|
||||
void Task::terminate() {}
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
|
||||
TaskState update(std::shared_ptr<Blackboard> blackboard);
|
||||
void reset(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void terminate(); // caution: this should only be called just before quitting the app.
|
||||
virtual void terminate(); // caution: this should only be called just before quitting the app.
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard) = 0;
|
||||
@@ -41,4 +41,4 @@ private:
|
||||
bool m_exitCalled = false;
|
||||
};
|
||||
|
||||
#endif // TASK_H
|
||||
#endif // TASK_H
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
#include "TaskRunner.h"
|
||||
|
||||
TaskDecorator::TaskDecorator()
|
||||
{
|
||||
}
|
||||
TaskDecorator::TaskDecorator() {}
|
||||
|
||||
std::shared_ptr<TaskDecorator> TaskDecorator::addChildTask(std::shared_ptr<Task> child)
|
||||
{
|
||||
|
||||
@@ -25,4 +25,4 @@ private:
|
||||
virtual void doTerminate();
|
||||
};
|
||||
|
||||
#endif // TASK_DECORATOR_H
|
||||
#endif // TASK_DECORATOR_H
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
#include <thread>
|
||||
|
||||
TaskDecoratorDelay::TaskDecoratorDelay(size_t delayMS)
|
||||
: m_delayMS(delayMS)
|
||||
, m_delayComplete(false)
|
||||
TaskDecoratorDelay::TaskDecoratorDelay(size_t delayMS): m_delayMS(delayMS), m_delayComplete(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -28,9 +26,7 @@ Task::TaskState TaskDecoratorDelay::doUpdate(std::shared_ptr<Blackboard> blackbo
|
||||
return Task::STATE_HOLD;
|
||||
}
|
||||
|
||||
void TaskDecoratorDelay::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskDecoratorDelay::doExit(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
void TaskDecoratorDelay::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#include "TaskRunner.h"
|
||||
#include "TimeStamp.h"
|
||||
|
||||
class TaskDecoratorDelay
|
||||
: public TaskDecorator
|
||||
class TaskDecoratorDelay: public TaskDecorator
|
||||
{
|
||||
public:
|
||||
TaskDecoratorDelay(size_t delayMS);
|
||||
@@ -26,4 +25,4 @@ private:
|
||||
bool m_delayComplete;
|
||||
};
|
||||
|
||||
#endif // TASK_DECORATOR_DELAY_H
|
||||
#endif // TASK_DECORATOR_DELAY_H
|
||||
|
||||
@@ -4,15 +4,11 @@
|
||||
#include <thread>
|
||||
|
||||
TaskDecoratorRepeat::TaskDecoratorRepeat(ConditionType condition, TaskState exitState, size_t delayMS)
|
||||
: m_condition(condition)
|
||||
, m_exitState(exitState)
|
||||
, m_delayMS(delayMS)
|
||||
: m_condition(condition), m_exitState(exitState), m_delayMS(delayMS)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDecoratorRepeat::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskDecoratorRepeat::doEnter(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
Task::TaskState TaskDecoratorRepeat::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
@@ -38,9 +34,7 @@ Task::TaskState TaskDecoratorRepeat::doUpdate(std::shared_ptr<Blackboard> blackb
|
||||
return state;
|
||||
}
|
||||
|
||||
void TaskDecoratorRepeat::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskDecoratorRepeat::doExit(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
void TaskDecoratorRepeat::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include "TaskDecorator.h"
|
||||
#include "TaskRunner.h"
|
||||
|
||||
class TaskDecoratorRepeat
|
||||
: public TaskDecorator
|
||||
class TaskDecoratorRepeat: public TaskDecorator
|
||||
{
|
||||
public:
|
||||
enum ConditionType
|
||||
@@ -28,4 +27,4 @@ private:
|
||||
const size_t m_delayMS;
|
||||
};
|
||||
|
||||
#endif // TASK_DECORATOR_REPEAT_H
|
||||
#endif // TASK_DECORATOR_REPEAT_H
|
||||
|
||||
@@ -2,24 +2,15 @@
|
||||
|
||||
#include "Blackboard.h"
|
||||
|
||||
TaskFindKeyOnBlackboard::TaskFindKeyOnBlackboard(const std::string& key)
|
||||
: m_key(key)
|
||||
{
|
||||
}
|
||||
TaskFindKeyOnBlackboard::TaskFindKeyOnBlackboard(const std::string& key): m_key(key) {}
|
||||
|
||||
void TaskFindKeyOnBlackboard::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskFindKeyOnBlackboard::doEnter(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
Task::TaskState TaskFindKeyOnBlackboard::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
return (blackboard->exists(m_key)) ? STATE_SUCCESS : STATE_FAILURE;
|
||||
}
|
||||
|
||||
void TaskFindKeyOnBlackboard::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskFindKeyOnBlackboard::doExit(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
void TaskFindKeyOnBlackboard::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskFindKeyOnBlackboard::doReset(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
class Blackboard;
|
||||
|
||||
class TaskFindKeyOnBlackboard:
|
||||
public Task
|
||||
class TaskFindKeyOnBlackboard: public Task
|
||||
{
|
||||
public:
|
||||
TaskFindKeyOnBlackboard(const std::string& valueName);
|
||||
@@ -22,4 +21,4 @@ private:
|
||||
const std::string m_key;
|
||||
};
|
||||
|
||||
#endif // TASK_FIND_KEY_ON_BLACKBOARD_H
|
||||
#endif // TASK_FIND_KEY_ON_BLACKBOARD_H
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "TaskGroup.h"
|
||||
|
||||
TaskGroup::TaskGroup()
|
||||
{
|
||||
}
|
||||
TaskGroup::TaskGroup() {}
|
||||
|
||||
std::shared_ptr<TaskGroup> TaskGroup::addChildTasks(std::shared_ptr<Task> child1)
|
||||
{
|
||||
@@ -10,14 +8,16 @@ std::shared_ptr<TaskGroup> TaskGroup::addChildTasks(std::shared_ptr<Task> child1
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
std::shared_ptr<TaskGroup> TaskGroup::addChildTasks(std::shared_ptr<Task> child1, std::shared_ptr<Task> child2)
|
||||
std::shared_ptr<TaskGroup> TaskGroup::addChildTasks(
|
||||
std::shared_ptr<Task> child1, std::shared_ptr<Task> child2)
|
||||
{
|
||||
addTask(child1);
|
||||
addTask(child2);
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
std::shared_ptr<TaskGroup> TaskGroup::addChildTasks(std::shared_ptr<Task> child1, std::shared_ptr<Task> child2, std::shared_ptr<Task> child3)
|
||||
std::shared_ptr<TaskGroup> TaskGroup::addChildTasks(
|
||||
std::shared_ptr<Task> child1, std::shared_ptr<Task> child2, std::shared_ptr<Task> child3)
|
||||
{
|
||||
addTask(child1);
|
||||
addTask(child2);
|
||||
|
||||
@@ -14,7 +14,8 @@ public:
|
||||
TaskGroup();
|
||||
std::shared_ptr<TaskGroup> addChildTasks(std::shared_ptr<Task> child1);
|
||||
std::shared_ptr<TaskGroup> addChildTasks(std::shared_ptr<Task> child1, std::shared_ptr<Task> child2);
|
||||
std::shared_ptr<TaskGroup> addChildTasks(std::shared_ptr<Task> child1, std::shared_ptr<Task> child2, std::shared_ptr<Task> child3);
|
||||
std::shared_ptr<TaskGroup> addChildTasks(
|
||||
std::shared_ptr<Task> child1, std::shared_ptr<Task> child2, std::shared_ptr<Task> child3);
|
||||
|
||||
virtual void addTask(std::shared_ptr<Task> task) = 0;
|
||||
void terminate() override;
|
||||
@@ -24,5 +25,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // TASK_GROUP_H
|
||||
#endif // TASK_GROUP_H
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include "ScopedFunctor.h"
|
||||
|
||||
TaskGroupParallel::TaskGroupParallel()
|
||||
: m_needsToStartThreads(true)
|
||||
, m_activeTaskCountMutex(std::make_shared<std::mutex>())
|
||||
: m_needsToStartThreads(true), m_activeTaskCountMutex(std::make_shared<std::mutex>())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -28,7 +27,11 @@ void TaskGroupParallel::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_tasks[i]->active = true;
|
||||
m_tasks[i]->thread = std::make_shared<std::thread>(
|
||||
&TaskGroupParallel::processTaskThreaded, this, m_tasks[i], blackboard, m_activeTaskCountMutex);
|
||||
&TaskGroupParallel::processTaskThreaded,
|
||||
this,
|
||||
m_tasks[i],
|
||||
blackboard,
|
||||
m_activeTaskCountMutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +71,11 @@ void TaskGroupParallel::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
m_tasks[i]->thread->join();
|
||||
m_tasks[i]->active = true;
|
||||
m_tasks[i]->thread = std::make_shared<std::thread>(
|
||||
&TaskGroupParallel::processTaskThreaded, this, m_tasks[i], blackboard, m_activeTaskCountMutex);
|
||||
&TaskGroupParallel::processTaskThreaded,
|
||||
this,
|
||||
m_tasks[i],
|
||||
blackboard,
|
||||
m_activeTaskCountMutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,7 +102,7 @@ void TaskGroupParallel::processTaskThreaded(
|
||||
std::shared_ptr<Blackboard> blackboard,
|
||||
std::shared_ptr<std::mutex> activeTaskCountMutex)
|
||||
{
|
||||
ScopedFunctor functor([&](){
|
||||
ScopedFunctor functor([&]() {
|
||||
std::lock_guard<std::mutex> lock(*activeTaskCountMutex.get());
|
||||
m_activeTaskCount--;
|
||||
});
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
#include "TaskGroup.h"
|
||||
#include "TaskRunner.h"
|
||||
|
||||
class TaskGroupParallel
|
||||
: public TaskGroup
|
||||
class TaskGroupParallel: public TaskGroup
|
||||
{
|
||||
public:
|
||||
TaskGroupParallel();
|
||||
@@ -19,10 +18,7 @@ public:
|
||||
private:
|
||||
struct TaskInfo
|
||||
{
|
||||
TaskInfo(std::shared_ptr<TaskRunner> taskRunner)
|
||||
: taskRunner(taskRunner)
|
||||
, active(false)
|
||||
{}
|
||||
TaskInfo(std::shared_ptr<TaskRunner> taskRunner): taskRunner(taskRunner), active(false) {}
|
||||
std::shared_ptr<TaskRunner> taskRunner;
|
||||
std::shared_ptr<std::thread> thread;
|
||||
volatile bool active;
|
||||
@@ -48,4 +44,4 @@ private:
|
||||
mutable std::shared_ptr<std::mutex> m_activeTaskCountMutex;
|
||||
};
|
||||
|
||||
#endif // TASK_GROUP_PARALLEL_H
|
||||
#endif // TASK_GROUP_PARALLEL_H
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#include "TaskGroupSelector.h"
|
||||
|
||||
TaskGroupSelector::TaskGroupSelector()
|
||||
: m_taskIndex(0)
|
||||
{
|
||||
}
|
||||
TaskGroupSelector::TaskGroupSelector(): m_taskIndex(0) {}
|
||||
|
||||
void TaskGroupSelector::addTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
@@ -45,9 +42,7 @@ Task::TaskState TaskGroupSelector::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
return STATE_RUNNING;
|
||||
}
|
||||
|
||||
void TaskGroupSelector::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskGroupSelector::doExit(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
void TaskGroupSelector::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "TaskGroup.h"
|
||||
#include "TaskRunner.h"
|
||||
|
||||
class TaskGroupSelector
|
||||
: public TaskGroup
|
||||
class TaskGroupSelector: public TaskGroup
|
||||
{
|
||||
public:
|
||||
TaskGroupSelector();
|
||||
@@ -23,4 +22,4 @@ private:
|
||||
int m_taskIndex;
|
||||
};
|
||||
|
||||
#endif // TASK_GROUP_SELECTOR_H
|
||||
#endif // TASK_GROUP_SELECTOR_H
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "TaskGroupSequence.h"
|
||||
|
||||
TaskGroupSequence::TaskGroupSequence()
|
||||
{
|
||||
}
|
||||
TaskGroupSequence::TaskGroupSequence() {}
|
||||
|
||||
void TaskGroupSequence::addTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
@@ -43,9 +41,7 @@ Task::TaskState TaskGroupSequence::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
return STATE_RUNNING;
|
||||
}
|
||||
|
||||
void TaskGroupSequence::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskGroupSequence::doExit(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
void TaskGroupSequence::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "TaskGroup.h"
|
||||
#include "TaskRunner.h"
|
||||
|
||||
class TaskGroupSequence
|
||||
: public TaskGroup
|
||||
class TaskGroupSequence: public TaskGroup
|
||||
{
|
||||
public:
|
||||
TaskGroupSequence();
|
||||
@@ -23,4 +22,4 @@ private:
|
||||
int m_taskIndex;
|
||||
};
|
||||
|
||||
#endif // TASK_GROUP_SEQUENCE_H
|
||||
#endif // TASK_GROUP_SEQUENCE_H
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
#include "TaskLambda.h"
|
||||
|
||||
TaskLambda::TaskLambda(std::function<void()> func)
|
||||
: m_func(func)
|
||||
{
|
||||
}
|
||||
TaskLambda::TaskLambda(std::function<void()> func): m_func(func) {}
|
||||
|
||||
void TaskLambda::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskLambda::doEnter(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
Task::TaskState TaskLambda::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
@@ -15,10 +10,6 @@ Task::TaskState TaskLambda::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
void TaskLambda::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskLambda::doExit(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
void TaskLambda::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
void TaskLambda::doReset(std::shared_ptr<Blackboard> blackboard) {}
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
#include "Task.h"
|
||||
|
||||
class TaskLambda
|
||||
: public Task
|
||||
class TaskLambda: public Task
|
||||
{
|
||||
public:
|
||||
TaskLambda(std::function<void()> func);
|
||||
@@ -20,4 +19,4 @@ private:
|
||||
std::function<void()> m_func;
|
||||
};
|
||||
|
||||
#endif // LAMBDA_TASK_H
|
||||
#endif // LAMBDA_TASK_H
|
||||
|
||||
@@ -22,4 +22,4 @@ private:
|
||||
static std::mutex s_schedulersMutex;
|
||||
};
|
||||
|
||||
#endif // TASK_MANAGER_H
|
||||
#endif // TASK_MANAGER_H
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#ifndef TASK_RETURN_SUCCESS_IF_H
|
||||
#define TASK_RETURN_SUCCESS_IF_H
|
||||
|
||||
#include "Task.h"
|
||||
#include "Blackboard.h"
|
||||
#include "Task.h"
|
||||
|
||||
template <typename T>
|
||||
class TaskReturnSuccessIf:
|
||||
public Task
|
||||
class TaskReturnSuccessIf: public Task
|
||||
{
|
||||
public:
|
||||
enum ConditionType
|
||||
@@ -29,10 +28,9 @@ private:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
TaskReturnSuccessIf<T>::TaskReturnSuccessIf(const std::string& lhsValueName, ConditionType condition, T rhsValue)
|
||||
: m_lhsValueName(lhsValueName)
|
||||
, m_condition(condition)
|
||||
, m_rhsValue(rhsValue)
|
||||
TaskReturnSuccessIf<T>::TaskReturnSuccessIf(
|
||||
const std::string& lhsValueName, ConditionType condition, T rhsValue)
|
||||
: m_lhsValueName(lhsValueName), m_condition(condition), m_rhsValue(rhsValue)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -75,4 +73,4 @@ void TaskReturnSuccessIf<T>::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
#endif // TASK_RETURN_SUCCESS_IF_H
|
||||
#endif // TASK_RETURN_SUCCESS_IF_H
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
#include "TaskRunner.h"
|
||||
|
||||
#include "Blackboard.h"
|
||||
#include "logging.h"
|
||||
#include "TaskManager.h"
|
||||
#include "TaskScheduler.h"
|
||||
#include "logging.h"
|
||||
|
||||
TaskRunner::TaskRunner(std::shared_ptr<Task> task)
|
||||
: m_task(task)
|
||||
, m_reset(false)
|
||||
{
|
||||
}
|
||||
TaskRunner::TaskRunner(std::shared_ptr<Task> task): m_task(task), m_reset(false) {}
|
||||
|
||||
Task::TaskState TaskRunner::update(Id schedulerId)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
Task::TaskState update(Id schedulerId);
|
||||
Task::TaskState update(std::shared_ptr<Blackboard> blackboard);
|
||||
void reset();
|
||||
void terminate(); // caution: this should only be called just before quitting the app.
|
||||
void terminate(); // caution: this should only be called just before quitting the app.
|
||||
|
||||
private:
|
||||
std::shared_ptr<Task> m_task;
|
||||
@@ -23,4 +23,4 @@ private:
|
||||
std::shared_ptr<Blackboard> m_blackboard;
|
||||
};
|
||||
|
||||
#endif // TASK_RUNNER_H
|
||||
#endif // TASK_RUNNER_H
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "logging.h"
|
||||
#include "ScopedFunctor.h"
|
||||
#include "logging.h"
|
||||
|
||||
TaskScheduler::TaskScheduler(Id schedulerId)
|
||||
: m_schedulerId(schedulerId)
|
||||
@@ -141,9 +141,7 @@ void TaskScheduler::processTasks()
|
||||
|
||||
{
|
||||
m_tasksMutex.unlock();
|
||||
ScopedFunctor functor([this](){
|
||||
m_tasksMutex.lock();
|
||||
});
|
||||
ScopedFunctor functor([this]() { m_tasksMutex.lock(); });
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef TASK_SCHEDULER_H
|
||||
#define TASK_SCHEDULER_H
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <deque>
|
||||
|
||||
#include "Task.h"
|
||||
#include "TaskRunner.h"
|
||||
@@ -43,4 +43,4 @@ private:
|
||||
mutable std::mutex m_threadMutex;
|
||||
};
|
||||
|
||||
#endif // TASK_SCHEDULER_H
|
||||
#endif // TASK_SCHEDULER_H
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#ifndef TASK_SET_VALUE_H
|
||||
#define TASK_SET_VALUE_H
|
||||
|
||||
#include "Task.h"
|
||||
#include "Blackboard.h"
|
||||
#include "Task.h"
|
||||
|
||||
template <typename T>
|
||||
class TaskSetValue:
|
||||
public Task
|
||||
class TaskSetValue: public Task
|
||||
{
|
||||
public:
|
||||
TaskSetValue(const std::string& valueName, T value);
|
||||
@@ -23,8 +22,7 @@ private:
|
||||
|
||||
template <typename T>
|
||||
TaskSetValue<T>::TaskSetValue(const std::string& valueName, T value)
|
||||
: m_valueName(valueName)
|
||||
, m_value(value)
|
||||
: m_valueName(valueName), m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -50,4 +48,4 @@ void TaskSetValue<T>::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
#endif // TASK_SET_VALUE_H
|
||||
#endif // TASK_SET_VALUE_H
|
||||
|
||||
Reference in New Issue
Block a user