#pragma once
#include <folly/File.h>
#include <folly/experimental/io/IoUringBackend.h>
#include <folly/experimental/io/Liburing.h>
#include <folly/io/async/EventBase.h>
#include <folly/io/async/EventHandler.h>
namespace folly {
#if FOLLY_HAS_LIBURING
class IoUringEvent : public EventHandler, public EventBase::LoopCallback {
public:
IoUringEvent(
folly::EventBase* eventBase,
IoUringBackend::Options const& o,
bool use_event_fd = true);
~IoUringEvent() override;
IoUringEvent const& operator=(IoUringEvent const&) = delete;
IoUringEvent&& operator=(IoUringEvent&&) = delete;
IoUringEvent(IoUringEvent&&) = delete;
IoUringEvent(IoUringEvent const&) = delete;
void handlerReady(uint16_t events) noexcept override;
void runLoopCallback() noexcept override;
IoUringBackend& backend() { return backend_; }
private:
bool hasWork();
EventBase* eventBase_;
IoUringBackend backend_;
bool lastWasResignalled_ = false;
bool edgeTriggered_ = false;
std::optional<File> eventFd_;
};
#endif
}