feat(IO): add portable Driver/ByteStream/BufferLease, mock backend, and Linux epoll driver (S-IO-01, S-IO-02)

This commit is contained in:
faumaray committed 2026-11-24 09:31:13 +03:00
1 parent 9918ed4760
commit 673bb7e8b4
10 files changed
+3071

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 4.0)
project(VoidIOOnlyConsumer LANGUAGES CXX)
find_package(Void CONFIG REQUIRED COMPONENTS IO)
add_executable(void_io_only_consumer main.cpp)
target_link_libraries(void_io_only_consumer PRIVATE Void::IO)
enable_testing()
add_test(NAME VoidIOOnlyConsumer COMMAND void_io_only_consumer)
+35
View File
@@ -0,0 +1,35 @@
#include <Void/Async/Executor.hpp>
#include <Void/Async/TaskScope.hpp>
#include <Void/IO/Driver.hpp>
#include <Void/IO/Stream.hpp>
#include <cstring>
int main()
{
Void::Async::ManualExecutor exec;
auto drv_res = Void::IO::Driver::create(
exec, Void::IO::BackendOptions{.preference = Void::IO::BackendPreference::mock});
if (!drv_res.has_value()) {
return 1;
}
auto& driver = **drv_res;
auto buf = driver.allocate_buffer(32);
auto stream = driver.create_mock_stream();
if (!buf.has_value() || !stream.has_value()) {
return 1;
}
std::memset(buf->writable().data(), 'x', buf->size());
#ifdef __linux__
auto ep = Void::IO::Driver::create(
exec, Void::IO::BackendOptions{.preference = Void::IO::BackendPreference::epoll});
if (!ep.has_value()) {
return 1;
}
auto pair_res = (*ep)->create_socket_pair();
if (!pair_res.has_value()) {
return 1;
}
#endif
return 0;
}
+5
View File
@@ -106,6 +106,11 @@ if(_has_unicode)
run_consumer(UnicodeOnly "${install_prefix}" "UnicodeOnly" ${_no_external_deps})
endif()
has_modules(_has_io IO Async Memory Time Functional Core)
if(_has_io)
run_consumer(IOOnly "${install_prefix}" "IOOnly" ${_no_external_deps})
endif()
# Foundation consumer with Core-formatting bridge and zero external packages.
has_modules(_has_foundation Math Text Time Functional Binary FunctionalCoreFormatting Memory Core)
if(_has_foundation)