feat(IO): add portable Driver/ByteStream/BufferLease, mock backend, and Linux epoll driver (S-IO-01, S-IO-02)
This commit is contained in:
1 parent
9918ed4760
commit
673bb7e8b4
10 files changed
+3071
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user