src/corosio/src/timer.cpp

100.0% Lines (18/18) 100.0% Functions (8/8) 75.0% Branches (3/4)
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 2115 timer::~timer() = default;
17
18 2113 timer::timer(capy::execution_context& ctx)
19
1/1
✓ Branch 3 → 4 taken 2113 times.
2113 : io_timer(handle(ctx, detail::timer_service_direct(ctx)))
20 {
21 2113 }
22
23 1 timer::timer(capy::execution_context& ctx, time_point t) : timer(ctx)
24 {
25
1/1
✓ Branch 3 → 4 taken 1 time.
1 expires_at(t);
26 1 }
27
28 1 timer::timer(timer&& other) noexcept : io_timer(std::move(other)) {}
29
30 timer&
31 2 timer::operator=(timer&& other) noexcept
32 {
33
1/2
✓ Branch 2 → 3 taken 2 times.
✗ Branch 2 → 5 not taken.
2 if (this != &other)
34 2 h_ = std::move(other.h_);
35 2 return *this;
36 }
37
38 std::size_t
39 727 timer::do_cancel()
40 {
41 727 return detail::timer_service_cancel(get());
42 }
43
44 std::size_t
45 1 timer::do_cancel_one()
46 {
47 1 return detail::timer_service_cancel_one(get());
48 }
49
50 std::size_t
51 3 timer::do_update_expiry()
52 {
53 3 return detail::timer_service_update_expiry(get());
54 }
55
56 } // namespace boost::corosio
57