Skip to content

Instantly share code, notes, and snippets.

@MBkkt

MBkkt/kek.cpp Secret

Created May 27, 2023 16:31
Show Gist options
  • Save MBkkt/96d71e0cb69ed1a59ab3a8f9c0203393 to your computer and use it in GitHub Desktop.
Save MBkkt/96d71e0cb69ed1a59ab3a8f9c0203393 to your computer and use it in GitHub Desktop.
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