Skip to content

Commit

Permalink
outbox stale messages bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sdavtaker committed Oct 2, 2017
1 parent 9182ffe commit e00d0a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions include/cadmium/engine/pdevs_coordinator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ namespace cadmium {
return oss.str();
};

//cleanning the inbox and outbox for collecting new messages
_inbox = in_bags_type{};
_outbox = out_bags_type{};
//collecting if necessary
if (_next < t) {
throw std::domain_error("Trying to obtain output when not internal event is scheduled");
Expand All @@ -166,6 +163,9 @@ namespace cadmium {
* @param t is the time the transition is expected to be run.
*/
void advance_simulation(const TIME &t) {
//clean outbox because messages are routed before calling this funtion at a higher level
_outbox = out_bags_type{};

auto log_info_advance = [](const TIME& from, const TIME& to) -> std::string {
std::ostringstream oss;
oss << "Coordinator for model ";
Expand Down
3 changes: 3 additions & 0 deletions include/cadmium/engine/pdevs_simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ namespace cadmium {
* @param t is the time the transition is expected to be run.
*/
void advance_simulation(TIME t) {
//clean outbox because messages are routed before calling this funtion at a higher level
_outbox = out_bags_type{};

auto log_info_advance = [](const TIME& from, const TIME& to) -> std::string {
std::ostringstream oss;
oss << "Simulator for model ";
Expand Down
1 change: 0 additions & 1 deletion test/boxes_cleanup_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ BOOST_AUTO_TEST_CASE( simple_outbox_cleanup_bug_test){
std::string accum_states = "State for model cadmium::basic_models::accumulator";
cadmium::engine::runner<float, DTOP, log_time_and_state> r{0.0};
r.runUntil(5.0);
std::cout << oss.str();
int count_initial_states = count_matches(expected_initial_state, oss.str());
int count_expected_accumulation = count_matches(expected_accumulation_of_one, oss.str());
int count_accum_states = count_matches(accum_states, oss.str());
Expand Down

0 comments on commit e00d0a8

Please sign in to comment.