Files
wibo/src/async_io.h
Luke Street f2743d05e7 Add hybrid epoll/thread pool async I/O backend (#98)
* Add hybrid epoll/thread pool async I/O backend

* Remove thread pool in favor of epoll AIO backend
2025-10-23 23:09:52 -07:00

34 lines
872 B
C++

#pragma once
#include "kernel32/internal.h"
#include "kernel32/minwinbase.h"
#include <optional>
namespace wibo {
class AsyncIOBackend {
public:
virtual ~AsyncIOBackend() = default;
virtual bool init() = 0;
virtual void shutdown() = 0;
[[nodiscard]] virtual bool running() const noexcept = 0;
virtual bool queueRead(Pin<kernel32::FileObject> file, OVERLAPPED *ov, void *buffer, DWORD length,
const std::optional<off_t> &offset, bool isPipe) = 0;
virtual bool queueWrite(Pin<kernel32::FileObject> file, OVERLAPPED *ov, const void *buffer, DWORD length,
const std::optional<off_t> &offset, bool isPipe) = 0;
};
namespace detail {
#if WIBO_ENABLE_LIBURING
std::unique_ptr<AsyncIOBackend> createIoUringBackend();
#endif
std::unique_ptr<AsyncIOBackend> createEpollBackend();
} // namespace detail
AsyncIOBackend &asyncIO();
} // namespace wibo