include/boost/corosio/detail/intrusive.hpp
96.1% Lines (73/76)
100.0% List of functions (82/84)
37.6% Branches (231/614)
Functions (84)
Function
Calls
Lines
Branches
Blocks
<unknown function 43>
:43
–
–
–
–
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::intrusive_list()
:47
1452x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::intrusive_list()
:47
1452x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::intrusive_list()
:47
1452x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::intrusive_list()
:47
1452x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::intrusive_list()
:47
1452x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::intrusive_list()
:47
1452x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::intrusive_list()
:47
152x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::intrusive_list()
:47
2642x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::intrusive_list()
:47
2642x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::intrusive_list()
:47
2642x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::intrusive_list()
:47
2642x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::intrusive_list()
:47
1190x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::intrusive_list()
:47
1190x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::intrusive_list()
:47
1190x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::intrusive_list()
:47
1190x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::intrusive_list()
:47
1190x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::intrusive_list()
:47
1190x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::intrusive_list()
:47
2852122x
0.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::empty() const
:61
38x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::push_back(boost::corosio::detail::kqueue_local_datagram_socket*)
:72
92x
100.0%
40.4%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::push_back(boost::corosio::detail::kqueue_local_stream_acceptor*)
:72
27x
100.0%
–
62.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::push_back(boost::corosio::detail::kqueue_local_stream_socket*)
:72
85x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::push_back(boost::corosio::detail::kqueue_tcp_acceptor*)
:72
1159x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::push_back(boost::corosio::detail::kqueue_tcp_socket*)
:72
17085x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::push_back(boost::corosio::detail::kqueue_udp_socket*)
:72
104x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::push_back(boost::corosio::detail::posix_random_access_file::raf_op*)
:72
294x
100.0%
66.7%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::push_back(boost::corosio::detail::posix_random_access_file*)
:72
76x
100.0%
–
62.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::push_back(boost::corosio::detail::posix_resolver*)
:72
42x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::push_back(boost::corosio::detail::posix_signal*)
:72
108x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::push_back(boost::corosio::detail::posix_stream_file*)
:72
76x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::push_back(boost::corosio::detail::select_local_datagram_socket*)
:72
92x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::push_back(boost::corosio::detail::select_local_stream_acceptor*)
:72
27x
100.0%
–
62.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::push_back(boost::corosio::detail::select_local_stream_socket*)
:72
85x
81.8%
66.7%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::push_back(boost::corosio::detail::select_tcp_acceptor*)
:72
141x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::push_back(boost::corosio::detail::select_tcp_socket*)
:72
6736x
100.0%
66.7%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::push_back(boost::corosio::detail::select_udp_socket*)
:72
104x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::push_back(boost::corosio::detail::waiter_node*)
:72
15908x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::pop_front()
:103
726x
100.0%
12.2%
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::pop_front()
:103
726x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::pop_front()
:103
726x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::pop_front()
:103
726x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::pop_front()
:103
726x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::pop_front()
:103
726x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::pop_front()
:103
1321x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::pop_front()
:103
1321x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::pop_front()
:103
1321x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::pop_front()
:103
1321x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::pop_front()
:103
595x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::pop_front()
:103
595x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::pop_front()
:103
595x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::pop_front()
:103
595x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::pop_front()
:103
595x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::pop_front()
:103
595x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::pop_front()
:103
1449444x
0.0%
0.0%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::remove(boost::corosio::detail::kqueue_local_datagram_socket*)
:121
92x
92.3%
46.2%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::remove(boost::corosio::detail::kqueue_local_stream_acceptor*)
:121
27x
100.0%
–
57.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::remove(boost::corosio::detail::kqueue_local_stream_socket*)
:121
85x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::remove(boost::corosio::detail::kqueue_tcp_acceptor*)
:121
1159x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::remove(boost::corosio::detail::kqueue_tcp_socket*)
:121
17085x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::remove(boost::corosio::detail::kqueue_udp_socket*)
:121
104x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::remove(boost::corosio::detail::posix_random_access_file::raf_op*)
:121
294x
84.6%
50.0%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::remove(boost::corosio::detail::posix_random_access_file*)
:121
76x
100.0%
–
57.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::remove(boost::corosio::detail::posix_resolver*)
:121
42x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::remove(boost::corosio::detail::posix_signal*)
:121
108x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::remove(boost::corosio::detail::posix_stream_file*)
:121
76x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::remove(boost::corosio::detail::select_local_datagram_socket*)
:121
92x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::remove(boost::corosio::detail::select_local_stream_acceptor*)
:121
27x
100.0%
–
57.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::remove(boost::corosio::detail::select_local_stream_socket*)
:121
85x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::remove(boost::corosio::detail::select_tcp_acceptor*)
:121
141x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::remove(boost::corosio::detail::select_tcp_socket*)
:121
6736x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::remove(boost::corosio::detail::select_udp_socket*)
:121
104x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::remove(boost::corosio::detail::waiter_node*)
:121
36x
84.6%
58.3%
76.0%
void boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::for_each<boost::corosio::detail::posix_random_access_file::cancel()::'lambda'(boost::corosio::detail::posix_random_access_file::raf_op*)>(boost::corosio::detail::posix_random_access_file::cancel()::'lambda'(boost::corosio::detail::posix_random_access_file::raf_op*))
:141
216x
50.0%
25.0%
42.0%
<unknown function 179>
:179
–
–
–
–
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::intrusive_queue()
:183
2646x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::intrusive_queue()
:183
5894904x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::empty() const
:197
1586x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::empty() const
:197
11245947x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::push(boost::corosio::detail::pool_work_item*)
:202
374x
100.0%
50.0%
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::push(boost::corosio::detail::scheduler_op*)
:202
3435598x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::splice(boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>&)
:212
1729045x
90.0%
75.0%
85.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::pop()
:225
3031x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::pop()
:225
4818497x
100.0%
50.0%
100.0%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2025 Vinnie Falco ([email protected]) | |||
| 3 | // | |||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||
| 6 | // | |||
| 7 | // Official repository: https://github.com/cppalliance/corosio | |||
| 8 | // | |||
| 9 | ||||
| 10 | #ifndef BOOST_COROSIO_DETAIL_INTRUSIVE_HPP | |||
| 11 | #define BOOST_COROSIO_DETAIL_INTRUSIVE_HPP | |||
| 12 | ||||
| 13 | namespace boost::corosio::detail { | |||
| 14 | ||||
| 15 | /** An intrusive doubly linked list. | |||
| 16 | ||||
| 17 | This container provides O(1) push and pop operations for | |||
| 18 | elements that derive from @ref node. Elements are not | |||
| 19 | copied or moved; they are linked directly into the list. | |||
| 20 | ||||
| 21 | @tparam T The element type. Must derive from `intrusive_list<T>::node`. | |||
| 22 | */ | |||
| 23 | template<class T> | |||
| 24 | class intrusive_list | |||
| 25 | { | |||
| 26 | public: | |||
| 27 | /** Base class for list elements. | |||
| 28 | ||||
| 29 | Derive from this class to make a type usable with | |||
| 30 | @ref intrusive_list. The `next_` and `prev_` pointers | |||
| 31 | are private and accessible only to the list. | |||
| 32 | */ | |||
| 33 | class node | |||
| 34 | { | |||
| 35 | friend class intrusive_list; | |||
| 36 | ||||
| 37 | private: | |||
| 38 | T* next_; | |||
| 39 | T* prev_; | |||
| 40 | }; | |||
| 41 | ||||
| 42 | private: | |||
| 43 | 1439347x | T* head_ = nullptr; | ||
| 44 | 1439347x | T* tail_ = nullptr; | ||
| 45 | ||||
| 46 | public: | |||
| 47 | 4318041x | intrusive_list() = default; | ||
| 48 | ||||
| 49 | intrusive_list(intrusive_list&& other) noexcept | |||
| 50 | : head_(other.head_) | |||
| 51 | , tail_(other.tail_) | |||
| 52 | { | |||
| 53 | other.head_ = nullptr; | |||
| 54 | other.tail_ = nullptr; | |||
| 55 | } | |||
| 56 | ||||
| 57 | intrusive_list(intrusive_list const&) = delete; | |||
| 58 | intrusive_list& operator=(intrusive_list const&) = delete; | |||
| 59 | intrusive_list& operator=(intrusive_list&&) = delete; | |||
| 60 | ||||
| 61 | 38x | bool empty() const noexcept | ||
| 62 | { | |||
| 63 | 38x | return head_ == nullptr; | ||
| 64 | } | |||
| 65 | ||||
| 66 | /// Peek at the head element without removing it. | |||
| 67 | T* front() const noexcept | |||
| 68 | { | |||
| 69 | return head_; | |||
| 70 | } | |||
| 71 | ||||
| 72 | 42241x | void push_back(T* w) noexcept | ||
| 73 | { | |||
| 74 |
12/34✗ Branch 0 not taken.
✓ Branch 1 taken 17506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6929 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 76 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 76 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 141 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 104 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 27 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 92 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 1159 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 104 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 27 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 92 times.
|
42241x | auto* n = static_cast<node*>(w); | |
| 75 | 42241x | n->next_ = nullptr; | ||
| 76 | 42241x | n->prev_ = tail_; | ||
| 77 |
23/36✓ Branch 0 taken 16251 times.
✓ Branch 1 taken 17121 times.
✓ Branch 2 taken 6631 times.
✓ Branch 3 taken 232 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 98 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 74 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 76 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 132 times.
✓ Branch 16 taken 27 times.
✓ Branch 17 taken 77 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 27 times.
✓ Branch 22 taken 36 times.
✓ Branch 23 taken 56 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 1150 times.
✓ Branch 28 taken 27 times.
✓ Branch 29 taken 77 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 27 times.
✓ Branch 34 taken 36 times.
✓ Branch 35 taken 56 times.
|
42241x | if (tail_) | |
| 78 |
11/38✗ Branch 0 not taken.
✗ Branch 0 not taken.
✓ Branch 1 taken 16202 times.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6630 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 9 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 27 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 36 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 9 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 27 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 36 times.
|
23038x | static_cast<node*>(tail_)->next_ = w; | |
| 79 | else | |||
| 80 | 19203x | head_ = w; | ||
| 81 | 42241x | tail_ = w; | ||
| 82 | 42241x | } | ||
| 83 | ||||
| 84 | void splice_back(intrusive_list& other) noexcept | |||
| 85 | { | |||
| 86 | if (other.empty()) | |||
| 87 | return; | |||
| 88 | if (tail_) | |||
| 89 | { | |||
| 90 | static_cast<node*>(tail_)->next_ = other.head_; | |||
| 91 | static_cast<node*>(other.head_)->prev_ = tail_; | |||
| 92 | tail_ = other.tail_; | |||
| 93 | } | |||
| 94 | else | |||
| 95 | { | |||
| 96 | head_ = other.head_; | |||
| 97 | tail_ = other.tail_; | |||
| 98 | } | |||
| 99 | other.head_ = nullptr; | |||
| 100 | other.tail_ = nullptr; | |||
| 101 | } | |||
| 102 | ||||
| 103 | 1462654x | T* pop_front() noexcept | ||
| 104 | { | |||
| 105 |
18/34✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 1433572 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1321 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1321 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1321 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1321 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 595 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 595 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 595 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 595 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 595 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 595 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 726 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 726 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 726 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 726 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 726 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 726 times.
|
1462654x | if (!head_) | |
| 106 | 1446782x | return nullptr; | ||
| 107 | 15872x | T* w = head_; | ||
| 108 |
0/32✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
15872x | head_ = static_cast<node*>(head_)->next_; | |
| 109 |
2/34✓ Branch 0 taken 47 times.
✓ Branch 1 taken 15825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
15872x | if (head_) | |
| 110 |
0/32✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
47x | static_cast<node*>(head_)->prev_ = nullptr; | |
| 111 | else | |||
| 112 | 15825x | tail_ = nullptr; | ||
| 113 | // Defensive: clear stale linkage so remove() on a | |||
| 114 | // popped node cannot corrupt the list. | |||
| 115 |
0/32✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
15872x | auto* n = static_cast<node*>(w); | |
| 116 | 15872x | n->next_ = nullptr; | ||
| 117 | 15872x | n->prev_ = nullptr; | ||
| 118 | 15872x | return w; | ||
| 119 | 1462654x | } | ||
| 120 | ||||
| 121 | 26369x | void remove(T* w) noexcept | ||
| 122 | { | |||
| 123 |
16/34✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 76 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 76 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 6736 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 141 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 104 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 85 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 27 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 92 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 17085 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 1159 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 104 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 85 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 27 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 92 times.
|
26369x | auto* n = static_cast<node*>(w); | |
| 124 | // Already detached — nothing to do. | |||
| 125 |
69/144✓ Branch 0 taken 86 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 42 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 41 times.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 41 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 108 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 98 times.
✓ Branch 19 taken 10 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 98 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 76 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 74 times.
✓ Branch 27 taken 2 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 74 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 76 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 76 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✓ Branch 45 taken 76 times.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✓ Branch 48 taken 2322 times.
✓ Branch 49 taken 4414 times.
✓ Branch 50 taken 142 times.
✓ Branch 51 taken 2180 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 142 times.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 141 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 132 times.
✓ Branch 59 taken 9 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 132 times.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✓ Branch 64 taken 104 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 77 times.
✓ Branch 67 taken 27 times.
✗ Branch 68 not taken.
✓ Branch 69 taken 77 times.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 72 taken 72 times.
✓ Branch 73 taken 13 times.
✓ Branch 74 taken 49 times.
✓ Branch 75 taken 23 times.
✗ Branch 76 not taken.
✓ Branch 77 taken 49 times.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✓ Branch 80 taken 27 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 27 times.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✓ Branch 85 taken 27 times.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✓ Branch 88 taken 92 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 56 times.
✓ Branch 91 taken 36 times.
✗ Branch 92 not taken.
✓ Branch 93 taken 56 times.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✓ Branch 96 taken 5758 times.
✓ Branch 97 taken 11327 times.
✓ Branch 98 taken 1161 times.
✓ Branch 99 taken 4597 times.
✗ Branch 100 not taken.
✓ Branch 101 taken 1161 times.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 1159 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 1150 times.
✓ Branch 107 taken 9 times.
✗ Branch 108 not taken.
✓ Branch 109 taken 1150 times.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✓ Branch 112 taken 104 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 77 times.
✓ Branch 115 taken 27 times.
✗ Branch 116 not taken.
✓ Branch 117 taken 77 times.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✓ Branch 120 taken 72 times.
✓ Branch 121 taken 13 times.
✓ Branch 122 taken 49 times.
✓ Branch 123 taken 23 times.
✗ Branch 124 not taken.
✓ Branch 125 taken 49 times.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✓ Branch 128 taken 27 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 27 times.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✓ Branch 133 taken 27 times.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✓ Branch 136 taken 92 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 56 times.
✓ Branch 139 taken 36 times.
✗ Branch 140 not taken.
✓ Branch 141 taken 56 times.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
|
26369x | if (!n->next_ && !n->prev_ && head_ != w && tail_ != w) | |
| 126 | ✗ | return; | ||
| 127 |
30/36✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 98 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 74 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 76 times.
✓ Branch 12 taken 2217 times.
✓ Branch 13 taken 4519 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 132 times.
✓ Branch 16 taken 27 times.
✓ Branch 17 taken 77 times.
✓ Branch 18 taken 23 times.
✓ Branch 19 taken 62 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 27 times.
✓ Branch 22 taken 36 times.
✓ Branch 23 taken 56 times.
✓ Branch 24 taken 4684 times.
✓ Branch 25 taken 12401 times.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 1150 times.
✓ Branch 28 taken 27 times.
✓ Branch 29 taken 77 times.
✓ Branch 30 taken 23 times.
✓ Branch 31 taken 62 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 27 times.
✓ Branch 34 taken 36 times.
✓ Branch 35 taken 56 times.
|
26369x | if (n->prev_) | |
| 128 |
13/36✗ Branch 0 not taken.
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2217 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 9 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 27 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 23 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 36 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4684 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 9 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 27 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 23 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 36 times.
|
7104x | static_cast<node*>(n->prev_)->next_ = n->next_; | |
| 129 | else | |||
| 130 | 19265x | head_ = n->next_; | ||
| 131 |
22/36✓ Branch 0 taken 244 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 108 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 76 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 76 times.
✓ Branch 12 taken 4414 times.
✓ Branch 13 taken 2322 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 141 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 104 times.
✓ Branch 18 taken 13 times.
✓ Branch 19 taken 72 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 27 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 92 times.
✓ Branch 24 taken 11327 times.
✓ Branch 25 taken 5758 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 1159 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 104 times.
✓ Branch 30 taken 13 times.
✓ Branch 31 taken 72 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 27 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 92 times.
|
26369x | if (n->next_) | |
| 132 |
5/36✗ Branch 0 not taken.
✗ Branch 0 not taken.
✓ Branch 1 taken 242 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4414 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 13 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 11327 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 13 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
16011x | static_cast<node*>(n->next_)->prev_ = n->prev_; | |
| 133 | else | |||
| 134 | 10358x | tail_ = n->prev_; | ||
| 135 | 26369x | n->next_ = nullptr; | ||
| 136 | 26369x | n->prev_ = nullptr; | ||
| 137 | 26369x | } | ||
| 138 | ||||
| 139 | /// Invoke @p f for each element in the list. | |||
| 140 | template<class F> | |||
| 141 | 216x | void for_each(F f) | ||
| 142 | { | |||
| 143 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
216x | for (T* p = head_; p; p = static_cast<node*>(p)->next_) | |
| 144 | ✗ | f(p); | ||
| 145 | 216x | } | ||
| 146 | }; | |||
| 147 | ||||
| 148 | /** An intrusive singly linked FIFO queue. | |||
| 149 | ||||
| 150 | This container provides O(1) push and pop operations for | |||
| 151 | elements that derive from @ref node. Elements are not | |||
| 152 | copied or moved; they are linked directly into the queue. | |||
| 153 | ||||
| 154 | Unlike @ref intrusive_list, this uses only a single `next_` | |||
| 155 | pointer per node, saving memory at the cost of not supporting | |||
| 156 | O(1) removal of arbitrary elements. | |||
| 157 | ||||
| 158 | @tparam T The element type. Must derive from `intrusive_queue<T>::node`. | |||
| 159 | */ | |||
| 160 | template<class T> | |||
| 161 | class intrusive_queue | |||
| 162 | { | |||
| 163 | public: | |||
| 164 | /** Base class for queue elements. | |||
| 165 | ||||
| 166 | Derive from this class to make a type usable with | |||
| 167 | @ref intrusive_queue. The `next_` pointer is private | |||
| 168 | and accessible only to the queue. | |||
| 169 | */ | |||
| 170 | class node | |||
| 171 | { | |||
| 172 | friend class intrusive_queue; | |||
| 173 | ||||
| 174 | private: | |||
| 175 | T* next_; | |||
| 176 | }; | |||
| 177 | ||||
| 178 | private: | |||
| 179 | 2948775x | T* head_ = nullptr; | ||
| 180 | 2948775x | T* tail_ = nullptr; | ||
| 181 | ||||
| 182 | public: | |||
| 183 | 8846325x | intrusive_queue() = default; | ||
| 184 | ||||
| 185 | intrusive_queue(intrusive_queue&& other) noexcept | |||
| 186 | : head_(other.head_) | |||
| 187 | , tail_(other.tail_) | |||
| 188 | { | |||
| 189 | other.head_ = nullptr; | |||
| 190 | other.tail_ = nullptr; | |||
| 191 | } | |||
| 192 | ||||
| 193 | intrusive_queue(intrusive_queue const&) = delete; | |||
| 194 | intrusive_queue& operator=(intrusive_queue const&) = delete; | |||
| 195 | intrusive_queue& operator=(intrusive_queue&&) = delete; | |||
| 196 | ||||
| 197 | 11247533x | bool empty() const noexcept | ||
| 198 | { | |||
| 199 | 11247533x | return head_ == nullptr; | ||
| 200 | } | |||
| 201 | ||||
| 202 | 3435972x | void push(T* w) noexcept | ||
| 203 | { | |||
| 204 | 3435972x | w->next_ = nullptr; | ||
| 205 |
2/4✓ Branch 0 taken 1560131 times.
✓ Branch 1 taken 1875841 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3435972x | if (tail_) | |
| 206 | 1560131x | tail_->next_ = w; | ||
| 207 | else | |||
| 208 | 1875841x | head_ = w; | ||
| 209 | 3435972x | tail_ = w; | ||
| 210 | 3435972x | } | ||
| 211 | ||||
| 212 | 1729045x | void splice(intrusive_queue& other) noexcept | ||
| 213 | { | |||
| 214 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1729045 times.
|
1729045x | if (other.empty()) | |
| 215 | ✗ | return; | ||
| 216 |
2/2✓ Branch 0 taken 381430 times.
✓ Branch 1 taken 1347615 times.
|
1729045x | if (tail_) | |
| 217 | 381430x | tail_->next_ = other.head_; | ||
| 218 | else | |||
| 219 | 1347615x | head_ = other.head_; | ||
| 220 | 1729045x | tail_ = other.tail_; | ||
| 221 | 1729045x | other.head_ = nullptr; | ||
| 222 | 1729045x | other.tail_ = nullptr; | ||
| 223 | 1729045x | } | ||
| 224 | ||||
| 225 | 4821528x | T* pop() noexcept | ||
| 226 | { | |||
| 227 |
2/4✓ Branch 0 taken 3435972 times.
✓ Branch 1 taken 1385556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4821528x | if (!head_) | |
| 228 | 1385556x | return nullptr; | ||
| 229 | 3435972x | T* w = head_; | ||
| 230 | 3435972x | head_ = head_->next_; | ||
| 231 |
2/4✓ Branch 0 taken 1941561 times.
✓ Branch 1 taken 1494411 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3435972x | if (!head_) | |
| 232 | 1494411x | tail_ = nullptr; | ||
| 233 | // Defensive: clear stale linkage on popped node. | |||
| 234 | 3435972x | w->next_ = nullptr; | ||
| 235 | 3435972x | return w; | ||
| 236 | 4821528x | } | ||
| 237 | }; | |||
| 238 | ||||
| 239 | } // namespace boost::corosio::detail | |||
| 240 | ||||
| 241 | #endif | |||
| 242 |