10 namespace io = boost::asio;
14 : _owner{owner}, _ctx{}, _sd{_ctx, owner._file}, _thread{
17 std::cout <<
"XDMA: EventThread " << _owner._file.name() <<
" ctor\n";
23 std::cout <<
"XDMA: EventThread " << _owner._file.
name() <<
" dtor\n" << std::endl;
32 subscriptionDonePromise.set_value();
51 std::cout <<
"XDMA: waitForEvent " << _owner._file.
name() <<
"\n";
55 _sd.async_wait(io::posix::stream_descriptor::wait_read,
63 std::cout <<
"XDMA: readEvent " << _owner._file.
name() <<
"\n";
66 const std::string msg =
"EventThread::readEvent() I/O error: " + ec.message();
69 _sd.async_read_some(io::buffer(_result),
71 std::placeholders::_1,
78 std::cout <<
"XDMA: handleEvent " << _owner._file.
name() <<
"\n";
81 const std::string msg =
"EventThread::handleEvent() I/O error: " + ec.message();
84 if(bytes_transferred !=
sizeof(_result[0])) {
85 throw runtime_error(
"EventThread::handleEvent() incomplete read");
88 uint32_t numInterrupts = _result[0];
90 std::cout <<
"XDMA: Event " << _owner._file.
name() <<
" received: " << bytes_transferred <<
" bytes, "
91 << numInterrupts <<
" interrupts\n";
95 if(numInterrupts != 0) {
96 _owner._asyncDomain->distribute(
nullptr);
103 std::cout <<
"XDMA: timerEvent for " << _owner._file.
name() <<
"\n";
106 const std::string msg =
"EventThread::timerEvent() I/O error: " + ec.message();
118 : _backend(backend), _file{devicePath +
"/events" +
std::to_string(interruptIdx), O_RDONLY}, _asyncDomain{
122 _evtThread.reset(
nullptr);
127 subscriptionDonePromise.set_value();
130 _evtThread = std::make_unique<EventThread>(*
this, std::move(subscriptionDonePromise));