// SPDX-License-Identifier: LGPL-3.0-or-later // Copyright © 2020-2021 Florian Fischer #include <sys/eventfd.h> // for eventfd, EFD_SEMAPHORE #include <cassert> // for assert #include <cerrno> // for ECANCELED, ETIME #include <cstdint> // for uint64_t, int32_t #include "Common.hpp" // for DIE_MSG_ERRNO #include "io/Future.hpp" // for ReadFuture, TimeoutWrapper using emper::io::ReadFuture; using emper::io::TimeoutWrapper; void emperTest() { int efd = eventfd(0, EFD_SEMAPHORE); if (efd == -1) { DIE_MSG_ERRNO("eventfd failed"); } uint64_t read_buf; ReadFuture readFuture(efd, &read_buf, sizeof(read_buf), 0); TimeoutWrapper::Timespec ts = {.tv_sec = 1, .tv_nsec = 0}; TimeoutWrapper t(readFuture, ts); int32_t res = t.submitAndWait(); assert(res == -ETIME); res = readFuture.wait(); assert(res == -ECANCELED); }