#pragma once #include #include #include #include #include #include #include #include #include #include #include namespace Void::Storage { struct AsyncAdapterOptions { std::size_t max_pending_batches{64}; std::size_t max_pending_bytes{64ULL * 1024ULL * 1024ULL}; const Void::Time::MonotonicClock* clock{nullptr}; }; struct AsyncAdapterStats { std::size_t queued_writes{0}; std::size_t pending_bytes{0}; std::uint64_t completed_writes{0}; std::uint64_t rejected_writes{0}; std::uint64_t unknown_outcomes{0}; std::uint64_t cancelled_before_append{0}; }; /// Bounded blocking async adapter over Storage::Engine following C-03 /// domain-result classification (never steals a persisted commit outcome with /// a synthetic timeout/cancel once WAL append begins; single delivery only). class AsyncStorageAdapter { public: explicit AsyncStorageAdapter( Engine& engine, AsyncAdapterOptions options = {}, Void::Async::Executor* completion_executor = nullptr); ~AsyncStorageAdapter(); AsyncStorageAdapter(const AsyncStorageAdapter&) = delete; AsyncStorageAdapter& operator=(const AsyncStorageAdapter&) = delete; AsyncStorageAdapter(AsyncStorageAdapter&&) = delete; AsyncStorageAdapter& operator=(AsyncStorageAdapter&&) = delete; [[nodiscard]] Void::Coro::Task> write_async( Batch batch, Durability durability, Void::Async::OperationOptions op = {}); [[nodiscard]] Void::Coro::Task> get_async( ByteView key, Void::Async::OperationOptions op = {}); [[nodiscard]] Void::Coro::Task> checkpoint_async(Void::Async::OperationOptions op = {}); [[nodiscard]] AsyncAdapterStats stats() const noexcept; void close_and_join(); private: struct Impl; std::shared_ptr m_impl{}; }; } // namespace Void::Storage