diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2026-06-19 19:47:03 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2026-06-19 19:47:40 +0200 |
| commit | 90fa52db708c42d9707581156b957da99987bd1c (patch) | |
| tree | 5afd9b4daf9254cd969b9d3f8082af46bedb19a5 /ttwhy/io.cppm | |
| parent | 7da39cd68d2bed2f49452ac5f9a3c01c52d0c5ba (diff) | |
| download | ttwhy-90fa52db708c42d9707581156b957da99987bd1c.tar.xz ttwhy-90fa52db708c42d9707581156b957da99987bd1c.zip | |
lib/scanners: inject scanner sink
Diffstat (limited to 'ttwhy/io.cppm')
| -rw-r--r-- | ttwhy/io.cppm | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ttwhy/io.cppm b/ttwhy/io.cppm index 5fd5e50..4b83996 100644 --- a/ttwhy/io.cppm +++ b/ttwhy/io.cppm @@ -3,7 +3,7 @@ module; #include <asio.hpp> #include <asio/experimental/awaitable_operators.hpp> -#include <chrono> +#include <chrono> // IWYU pragma: keep #include <format> #include <span> #include <vector> @@ -71,7 +71,11 @@ namespace ttwhy::io auto queue = std::vector<scanners::input_event>{}; queue.reserve(16); - auto scanner = scanners::ansi{queue}; + auto sink = [&queue](auto const & event) { + queue.push_back(event); + }; + auto scanner = scanners::ansi{sink}; + auto raw_buffer = std::array<char, 64>{}; while (true) @@ -81,7 +85,7 @@ namespace ttwhy::io if (scanner.is_pending()) { - timer.expires_after(500ms); + timer.expires_after(50ms); auto result = co_await (stream.async_read_some(asio::buffer(raw_buffer), asio::as_tuple(asio::use_awaitable)) || timer.async_wait(asio::as_tuple(asio::use_awaitable))); |
