diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-03-15 14:41:47 +0100 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-03-15 14:41:47 +0100 |
commit | c0424e7a55250705579ee64c269892677fa86adf (patch) | |
tree | 59f15a90bc14dffbecd139043420077a446c6d8e /modules/async | |
parent | b08872bc9a475559491659f5fea8f45a063cf1bf (diff) |
async,io: Fixed immediate issues in async and built a basic io
echo_server
Diffstat (limited to 'modules/async')
-rw-r--r-- | modules/async/c++/async.tmpl.hpp | 9 | ||||
-rw-r--r-- | modules/async/tests/immediate.cpp | 6 |
2 files changed, 6 insertions, 9 deletions
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 <typename T> size_t immediate_conveyor_node<T>::space() const { } template <typename T> size_t immediate_conveyor_node<T>::queued() const { - return retrieved_ > 1 ? 0 : 1; + return retrieved_ > 0 ? 0 : 1; } template <typename T> void immediate_conveyor_node<T>::child_has_fired() { @@ -301,15 +301,10 @@ template <typename T> void immediate_conveyor_node<T>::parent_has_fired() { arm_next(); } } -} -#include <iostream> -namespace saw { + template <typename T> void immediate_conveyor_node<T>::fire() { - std::cout<<"Immediate fire"<<std::endl; if (parent_) { - std::cout<<"Immediate parent: "<<queued()<<" "<<parent_->space()<<std::endl; parent_->child_has_fired(); - std::cout<<"Immediate parent2: "<<queued()<<" "<<parent_->space()<<std::endl; if (queued() > 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<int> 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"); } } |