Skip to content

Commit 112949e

Browse files
author
Marcus Huang
committed
impl
add test precommit comment fixup
1 parent d01d96d commit 112949e

File tree

13 files changed

+222
-160
lines changed

13 files changed

+222
-160
lines changed

alica_engine/include/engine/AlicaContext.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class AlicaContext
245245
*
246246
* @see AlicaCreators
247247
*/
248-
int init(AlicaCreators&& creatorCtx, bool delayStart = false);
248+
int init(AlicaCreators&& creatorCtx, bool delayStart = false, bool singleThreaded = false);
249249

250250
/**
251251
* Terminate alica framework and related modules. This function must be called for safe termination before
@@ -397,10 +397,15 @@ class AlicaContext
397397
AgentId getLocalAgentId() const;
398398

399399
/**
400-
* Execute one step of engine synchronously
400+
* Signal to execute one step of engine in multi-threaded mode.
401401
*/
402402
void stepEngine();
403403

404+
/**
405+
* Execute one step of engine in single-threaded mode.
406+
*/
407+
void stepEngineSync();
408+
404409
/**
405410
* Getter for the agents configuration.
406411
*

alica_engine/include/engine/AlicaEngine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ class AlicaEngine
4444

4545
// State modifiers:
4646
bool init(AlicaCreators&& creatorCtx);
47-
void start();
47+
void start(bool singleThreaded = false);
4848
void terminate();
4949
void stepNotify();
50+
void step();
5051

5152
// Parameter Access:
5253
// bool getStepEngine() const;

alica_engine/include/engine/PlanBase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <math.h>
1313
#include <memory>
1414
#include <mutex>
15+
#include <optional>
1516
#include <queue>
1617
#include <stdio.h>
1718
#include <thread>
@@ -57,7 +58,8 @@ class PlanBase
5758
const AlicaTime getLoopInterval() const;
5859
void setLoopInterval(AlicaTime loopInterval);
5960
void stop();
60-
void start(const Plan* masterPlan);
61+
void start(const Plan* masterPlan, bool singleThreaded = false);
62+
void tick(const Plan* masterPlan, AlicaTime beginTime = AlicaTime::zero());
6163
void addFastPathEvent(RunningPlan* p);
6264
bool isWaiting() const { return _isWaiting; }
6365

alica_engine/src/engine/AlicaContext.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int AlicaContext::init(AlicaCreators& creatorCtx)
7676
return init(std::move(creators));
7777
}
7878

79-
int AlicaContext::init(AlicaCreators&& creatorCtx, bool delayStart)
79+
int AlicaContext::init(AlicaCreators&& creatorCtx, bool delayStart, bool singleThreaded)
8080
{
8181
if (_initialized) {
8282
Logging::logWarn(LOGNAME) << "Context already initialized.";
@@ -99,7 +99,7 @@ int AlicaContext::init(AlicaCreators&& creatorCtx, bool delayStart)
9999
gbb.set("agentName", _engine->getLocalAgentName());
100100
gbb.set("agentId", _engine->getTeamManager().getLocalAgentID());
101101
if (!delayStart) {
102-
_engine->start();
102+
_engine->start(singleThreaded);
103103
} else {
104104
Logging::logInfo(LOGNAME) << "engine start delayed";
105105
}
@@ -150,6 +150,11 @@ void AlicaContext::stepEngine()
150150
} while (!_engine->editPlanBase().isWaiting());
151151
}
152152

153+
void AlicaContext::stepEngineSync()
154+
{
155+
_engine->step();
156+
}
157+
153158
AgentId AlicaContext::getLocalAgentId() const
154159
{
155160
return _engine->getTeamManager().getLocalAgentID();

alica_engine/src/engine/AlicaEngine.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ bool AlicaEngine::init(AlicaCreators&& creatorCtx)
106106
return true;
107107
}
108108

109-
void AlicaEngine::start()
109+
void AlicaEngine::start(bool singleThreaded)
110110
{
111111
// TODO: Removing this api need major refactoring of unit tests.
112-
_planBase.start(_masterPlan);
112+
_planBase.start(_masterPlan, singleThreaded);
113113
Logging::logInfo(LOGNAME) << "Engine started!";
114114
}
115115
/**
@@ -194,6 +194,11 @@ void AlicaEngine::stepNotify()
194194
_planBase.stepNotify();
195195
}
196196

197+
void AlicaEngine::step()
198+
{
199+
_planBase.tick(_masterPlan, getAlicaClock().now());
200+
}
201+
197202
void AlicaEngine::reloadConfig(const YAML::Node& config)
198203
{
199204
_configChangeListener.reloadConfig(config);

0 commit comments

Comments
 (0)