-
-
Save MBkkt/96d71e0cb69ed1a59ab3a8f9c0203393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Operation : yaclib::detail::Node { | |
virtual void SetUp(io_uring_sqe& sqe) = 0; | |
}; | |
struct SqeAwaiter : Operation { | |
yaclib::BaseCore* core; | |
int res; | |
}; | |
struct ReadAwaiter : SqeAwaiter { | |
bool await_ready() const { | |
return false; | |
} | |
void await_suspend(yaclib_std::coroutine_handle<Promise> h) { | |
handle = &h.promise(); | |
ctx.Submit(...); | |
} | |
void SetUp(io_uring_sqe& sqe) final { | |
sqe = sqe; | |
io_uring_prep_read(sqe, ...); | |
io_uring_sqe_set_data(sqe, handle.address()); | |
} | |
int await_resume() { | |
return res; | |
} | |
sqe | |
}; | |
struct Context { | |
void Submit(Operation& operation); | |
void Submit(std::span<Operation> operation) { | |
if (stopped) { | |
} | |
} | |
void Run() { | |
get_all_from_my_queue(...); | |
io_uring_submit_and_wait(1); | |
io_uring_for_each(...) { | |
core->_executor.Submit(*core); | |
} | |
} | |
void Stop() { | |
queue.store(...); | |
} | |
MPSC stack; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment