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.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/libtransport/src/utils/fd_deadline_timer.h b/libtransport/src/utils/fd_deadline_timer.h
index 22c13a763..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,6 +16,7 @@
#pragma once
#include <hicn/transport/errors/runtime_exception.h>
+#include <hicn/transport/utils/chrono_typedefs.h>
#include <sys/timerfd.h>
#include <unistd.h>
#include <utils/deadline_timer.h>
@@ -37,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>
@@ -51,8 +57,8 @@ 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;
@@ -86,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,