aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/utils/fd_deadline_timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/src/utils/fd_deadline_timer.h')
-rw-r--r--libtransport/src/utils/fd_deadline_timer.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/libtransport/src/utils/fd_deadline_timer.h b/libtransport/src/utils/fd_deadline_timer.h
index 8bc3bbca3..7ecbba69b 100644
--- a/libtransport/src/utils/fd_deadline_timer.h
+++ b/libtransport/src/utils/fd_deadline_timer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -16,17 +16,15 @@
#pragma once
#include <hicn/transport/errors/runtime_exception.h>
-#include <hicn/transport/utils/log.h>
-
+#include <hicn/transport/utils/chrono_typedefs.h>
+#include <sys/timerfd.h>
+#include <unistd.h>
#include <utils/deadline_timer.h>
#include <utils/epoll_event_reactor.h>
#include <chrono>
#include <cstddef>
-#include <sys/timerfd.h>
-#include <unistd.h>
-
namespace utils {
class FdDeadlineTimer : public DeadlineTimer<FdDeadlineTimer> {
@@ -40,6 +38,11 @@ class FdDeadlineTimer : public DeadlineTimer<FdDeadlineTimer> {
}
}
+ FdDeadlineTimer(const FdDeadlineTimer &other)
+ : reactor_(other.reactor_),
+ timer_fd_(other.timer_fd_),
+ flags_(other.flags_) {}
+
~FdDeadlineTimer() { close(timer_fd_); }
template <typename WaitHandler>
@@ -54,13 +57,13 @@ class FdDeadlineTimer : public DeadlineTimer<FdDeadlineTimer> {
reactor_.addFileDescriptor(
timer_fd_, events,
- [callback = std::forward<WaitHandler &&>(callback)](
- const Event &event) -> int {
+ [callback =
+ std::forward<WaitHandler>(callback)](const Event &event) -> int {
uint64_t s = 0;
std::error_code ec;
if (read(event.data.fd, &s, sizeof(s)) == -1) {
- TRANSPORT_LOGE("Read error!!");
+ LOG(ERROR) << "Read error!!";
}
if (!(event.events & EPOLLIN)) {
@@ -89,8 +92,7 @@ class FdDeadlineTimer : public DeadlineTimer<FdDeadlineTimer> {
template <typename T, typename R>
void expiresFromNowImpl(std::chrono::duration<T, R> &&duration) {
std::memset(&new_value_, 0, sizeof(new_value_));
- new_value_.it_value = std::chrono::duration_cast<struct timespec>(
- std::forward<std::chrono::duration<T, R>>(duration));
+ new_value_.it_value = std::chrono::duration_cast<struct timespec>(duration);
}
template <typename TimePoint,