blob: a5a2ae49b1f28d7811d72ea6f5547029599b557c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <forstio/io/io.hpp>
#include <iostream>
int main(){
auto eo_aio = saw::setup_async_io();
if(eo_aio.is_error()){
auto& err = eo_aio.get_error();
std::cerr<<"Error: "<<err.get_category();
auto err_msg = err.get_message();
if(err_msg.size() > 0u){
std::cerr<<" - "<<err_msg;
}
std::cerr<<std::endl;
return err.get_id();
}
auto& aio = eo_aio.get_value();
saw::wait_scope wait{aio.event_loop};
bool running = true;
aio.event_port.on_signal(saw::Signal::Terminate).then([&running](){
running = false;
}).detach();
while(running){
device->flush();
wait.wait(std::chrono::seconds{1u});
}
return 0;
}
|