Skip to content

Commit e00d0a8

Browse files
committed
outbox stale messages bug fix
1 parent 9182ffe commit e00d0a8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

include/cadmium/engine/pdevs_coordinator.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ namespace cadmium {
137137
return oss.str();
138138
};
139139

140-
//cleanning the inbox and outbox for collecting new messages
141-
_inbox = in_bags_type{};
142-
_outbox = out_bags_type{};
143140
//collecting if necessary
144141
if (_next < t) {
145142
throw std::domain_error("Trying to obtain output when not internal event is scheduled");
@@ -166,6 +163,9 @@ namespace cadmium {
166163
* @param t is the time the transition is expected to be run.
167164
*/
168165
void advance_simulation(const TIME &t) {
166+
//clean outbox because messages are routed before calling this funtion at a higher level
167+
_outbox = out_bags_type{};
168+
169169
auto log_info_advance = [](const TIME& from, const TIME& to) -> std::string {
170170
std::ostringstream oss;
171171
oss << "Coordinator for model ";

include/cadmium/engine/pdevs_simulator.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ namespace cadmium {
161161
* @param t is the time the transition is expected to be run.
162162
*/
163163
void advance_simulation(TIME t) {
164+
//clean outbox because messages are routed before calling this funtion at a higher level
165+
_outbox = out_bags_type{};
166+
164167
auto log_info_advance = [](const TIME& from, const TIME& to) -> std::string {
165168
std::ostringstream oss;
166169
oss << "Simulator for model ";

test/boxes_cleanup_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ BOOST_AUTO_TEST_CASE( simple_outbox_cleanup_bug_test){
201201
std::string accum_states = "State for model cadmium::basic_models::accumulator";
202202
cadmium::engine::runner<float, DTOP, log_time_and_state> r{0.0};
203203
r.runUntil(5.0);
204-
std::cout << oss.str();
205204
int count_initial_states = count_matches(expected_initial_state, oss.str());
206205
int count_expected_accumulation = count_matches(expected_accumulation_of_one, oss.str());
207206
int count_accum_states = count_matches(accum_states, oss.str());

0 commit comments

Comments
 (0)