35 lines
975 B
C++
35 lines
975 B
C++
#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;
|
|
} |