9 #include <sys/eventfd.h> 31 int64_t
read(
void* buf,
size_t buf_size)
override;
32 int64_t
write(
void* buf,
size_t buf_size)
override;
33 int64_t
readRT(
void* buf,
size_t buf_size)
override;
34 int64_t
writeRT(
void* buf,
size_t buf_size)
override;
36 void close()
override;
43 std::array<struct pollfd, 2> xbuf_poll_fd {};
51 this->xbuf_fd = evl_create_xbuf(fifo_capacity,
53 EVL_CLONE_PRIVATE | EVL_CLONE_NONBLOCK,
56 if (this->xbuf_fd <= 0) {
57 ERROR_MSG(
"RT::OS::FIFO(evl) : Unable to create real-time buffer\n");
58 ERROR_MSG(
"evl core : {}", strerror(this->xbuf_fd));
61 this->xbuf_poll_fd[0].fd = this->xbuf_fd;
62 this->xbuf_poll_fd[0].events = POLLIN;
63 this->close_event_fd = eventfd(0, EFD_NONBLOCK);
64 this->xbuf_poll_fd[1].fd = this->close_event_fd;
65 this->xbuf_poll_fd[1].events = POLLIN;
70 ::close(this->xbuf_fd);
76 return ::read(this->xbuf_fd, buf, buf_size);
82 return ::write(this->xbuf_fd, buf, buf_size);
87 return oob_read(this->xbuf_fd, buf, buf_size);
92 return oob_write(this->xbuf_fd, buf, buf_size);
97 int errcode = ::poll(this->xbuf_poll_fd.data(), 2, -1);
99 ERROR_MSG(
"RT::OS::FIFO(evl)::poll : returned with failure code {} : ",
102 }
else if ((this->xbuf_poll_fd[1].revents & POLLIN) != 0) {
109 return this->xbuf_fd;
114 std::array<int64_t, 1> buf {};
116 ::write(this->close_event_fd, buf.data(),
sizeof(int64_t));
121 return this->fifo_capacity;
127 auto tmp_fifo = std::make_unique<RT::OS::evlFifo>(fifo_size);
128 if (tmp_fifo->buffer_fd() < 0) {
129 init_state = tmp_fifo->buffer_fd();
130 ERROR_MSG(
"RT::OS::getFifo(EVL) : {}", strerror(errno));
132 fifo = std::move(tmp_fifo);
int64_t writeRT(void *buf, size_t buf_size) override
size_t getCapacity() override
int64_t readRT(void *buf, size_t buf_size) override
evlFifo & operator=(const evlFifo &fifo)=delete
evlFifo(const evlFifo &fifo)=delete
int64_t write(void *buf, size_t buf_size) override
evlFifo & operator=(evlFifo &&)=default
int64_t read(void *buf, size_t buf_size) override
evlFifo(evlFifo &&)=default
void ERROR_MSG(const std::string &errmsg, Args... args)
int getFifo(std::unique_ptr< Fifo > &fifo, size_t fifo_size)