From 8c25ce8d214db85656a1303ddc2740a9c6645f27 Mon Sep 17 00:00:00 2001 From: Paul Mathieu Date: Wed, 7 Jun 2023 09:59:54 +0200 Subject: [PATCH] arm: cleanup dead async code --- arm/async.cc | 29 +------------------------ arm/async.h | 61 ---------------------------------------------------- 2 files changed, 1 insertion(+), 89 deletions(-) diff --git a/arm/async.cc b/arm/async.cc index 62cebf8..647891d 100644 --- a/arm/async.cc +++ b/arm/async.cc @@ -165,31 +165,4 @@ void resume(AwaitableType type) { delete stuff; } -} // namespace async - -#if 0 - -task readline() { - int size = 0; - char c; - - buffer buff = buffer::make(32); - -// fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK); - - while (true) { - int n = read(0, &c, 1); - if (n < 1) { - co_await co_waitio(); - continue; - } - buff.data[size++] = static_cast(c); - - if (c == '\n') { - buff.data = buff.data.subspan(0, size); - co_return buff; - } - } -} - -#endif // 0 +} // namespace async \ No newline at end of file diff --git a/arm/async.h b/arm/async.h index 2ae5672..b7cc4ac 100644 --- a/arm/async.h +++ b/arm/async.h @@ -27,66 +27,6 @@ struct task_final_suspend { std::coroutine_handle<> parent; }; -#if 0 -template -struct gimme { - // child interface - bool await_ready() { return false; } - void await_suspend(std::coroutine_handle<> h) { - ha = h; - waiting = true; - TRACE(tracing::TraceEvent::kAsyncGimmeWaiting); - - if (parent) { - TRACE(tracing::TraceEvent::kAsyncCallParent); - parent.resume(); - TRACE(tracing::TraceEvent::kAsyncCallParentDone); - } - } - T await_resume() { - waiting = false; - TRACE(tracing::TraceEvent::kAsyncGimmeResume); - return std::move(stuff); - } - - // parent interface - auto feed(T&& s) { - struct awaitable { - bool await_ready() { - if (g.waiting) { - return true; - } - // TODO: handle g.ha.done() - return false; - } - void await_suspend(std::coroutine_handle<> h) { - g.parent = h; - } - void await_resume() {} - - gimme& g; - }; - - if (!waiting) { - __builtin_trap(); - } - if (!ha) { - __builtin_trap(); - } - stuff = s; - parent = {}; - ha.resume(); - - return awaitable{.g = *this}; - } - - bool waiting = false; - std::coroutine_handle<> ha; - T stuff; - std::coroutine_handle<> parent; -}; -#else - template struct gimme { // child interface @@ -118,7 +58,6 @@ struct gimme { std::coroutine_handle<> ha; T stuff; }; -#endif template struct task;