src/corosio/src/timer.cpp

100.0% Lines (19/19) 100.0% Functions (8/8) 33.3% Branches (2/6)
src/corosio/src/timer.cpp
Line Branch TLA Hits Source Code
1 //
2 // Copyright (c) 2025 Vinnie Falco ([email protected])
3 // Copyright (c) 2026 Steve Gerbino
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // Official repository: https://github.com/cppalliance/corosio
9 //
10
11 #include <boost/corosio/timer.hpp>
12 #include <boost/corosio/detail/timer_service.hpp>
13
14 namespace boost::corosio {
15
16 14606 timer::~timer() = default;
17
18 14600 timer::timer(capy::execution_context& ctx)
19 7305 : io_timer(handle(ctx, detail::timer_service_direct(ctx)))
20 14600 {
21 14600 }
22
23 2 timer::timer(capy::execution_context& ctx, time_point t) : timer(ctx)
24 {
25
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 expires_at(t);
26 2 }
27
28 4 timer::timer(timer&& other) noexcept : io_timer(std::move(other)) {}
29
30 timer&
31 4 timer::operator=(timer&& other) noexcept
32 {
33
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (this != &other)
34 4 h_ = std::move(other.h_);
35 4 return *this;
36 }
37
38 std::size_t
39 591 timer::do_cancel()
40 {
41 591 return detail::timer_service_cancel(get());
42 }
43
44 std::size_t
45 2 timer::do_cancel_one()
46 {
47 2 return detail::timer_service_cancel_one(get());
48 }
49
50 std::size_t
51 6 timer::do_update_expiry()
52 {
53 6 return detail::timer_service_update_expiry(get());
54 }
55
56 } // namespace boost::corosio
57