From c0424e7a55250705579ee64c269892677fa86adf Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 15 Mar 2024 14:41:47 +0100 Subject: async,io: Fixed immediate issues in async and built a basic io echo_server --- modules/async/c++/async.tmpl.hpp | 9 ++------- modules/async/tests/immediate.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'modules/async') diff --git a/modules/async/c++/async.tmpl.hpp b/modules/async/c++/async.tmpl.hpp index 98573b5..ec8d3fc 100644 --- a/modules/async/c++/async.tmpl.hpp +++ b/modules/async/c++/async.tmpl.hpp @@ -285,7 +285,7 @@ template size_t immediate_conveyor_node::space() const { } template size_t immediate_conveyor_node::queued() const { - return retrieved_ > 1 ? 0 : 1; + return retrieved_ > 0 ? 0 : 1; } template void immediate_conveyor_node::child_has_fired() { @@ -301,15 +301,10 @@ template void immediate_conveyor_node::parent_has_fired() { arm_next(); } } -} -#include -namespace saw { + template void immediate_conveyor_node::fire() { - std::cout<<"Immediate fire"<space()<child_has_fired(); - std::cout<<"Immediate parent2: "<space()< 0 && parent_->space() > 0) { arm_last(); } diff --git a/modules/async/tests/immediate.cpp b/modules/async/tests/immediate.cpp index a5d9b2f..5a59ccd 100644 --- a/modules/async/tests/immediate.cpp +++ b/modules/async/tests/immediate.cpp @@ -34,10 +34,11 @@ SAW_TEST("Immediate Conveyor Queueing"){ conveyor immediately_done{val}; int passed = 0; + bool has_failed = false; auto res = immediately_done.then([&passed](int a) { passed = a; - }).sink([](auto err){ - SAW_EXPECT(false, "No error should occur. This code path shouldn't be reachable."); + }).sink([&](auto err){ + has_failed = true; return err; }); @@ -48,5 +49,6 @@ SAW_TEST("Immediate Conveyor Queueing"){ wait.poll(); SAW_EXPECT(passed == val, "Expected a 5 in passed value."); + SAW_EXPECT(!has_failed, "No error should occur in queueing"); } } -- cgit v1.2.3