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
1326x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::intrusive_list()
:47
1326x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::intrusive_list()
:47
1326x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::intrusive_list()
:47
1326x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::intrusive_list()
:47
1326x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::intrusive_list()
:47
1326x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::intrusive_list()
:47
86x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::intrusive_list()
:47
2184x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::intrusive_list()
:47
2184x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::intrusive_list()
:47
2184x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::intrusive_list()
:47
2184x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::intrusive_list()
:47
858x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::intrusive_list()
:47
858x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::intrusive_list()
:47
858x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::intrusive_list()
:47
858x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::intrusive_list()
:47
858x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::intrusive_list()
:47
858x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::intrusive_list()
:47
2372704x
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*)
:66
63x
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*)
:66
22x
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*)
:66
68x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::push_back(boost::corosio::detail::kqueue_tcp_acceptor*)
:66
996x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::push_back(boost::corosio::detail::kqueue_tcp_socket*)
:66
13070x
100.0%
66.7%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::push_back(boost::corosio::detail::kqueue_udp_socket*)
:66
91x
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*)
:66
150x
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*)
:66
43x
100.0%
–
62.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::push_back(boost::corosio::detail::posix_resolver*)
:66
42x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::push_back(boost::corosio::detail::posix_signal*)
:66
104x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::push_back(boost::corosio::detail::posix_stream_file*)
:66
43x
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*)
:66
63x
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*)
:66
22x
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*)
:66
68x
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*)
:66
110x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::push_back(boost::corosio::detail::select_tcp_socket*)
:66
4877x
0.0%
0.0%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::push_back(boost::corosio::detail::select_udp_socket*)
:66
91x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::push_back(boost::corosio::detail::waiter_node*)
:66
12010x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::pop_front()
:97
663x
100.0%
12.2%
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::pop_front()
:97
663x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::pop_front()
:97
663x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::pop_front()
:97
663x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::pop_front()
:97
663x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::pop_front()
:97
663x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::pop_front()
:97
1092x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::pop_front()
:97
1092x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::pop_front()
:97
1092x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::pop_front()
:97
1092x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::pop_front()
:97
429x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::pop_front()
:97
429x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::pop_front()
:97
429x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::pop_front()
:97
429x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::pop_front()
:97
429x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::pop_front()
:97
429x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::pop_front()
:97
1203934x
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*)
:115
63x
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*)
:115
22x
100.0%
–
57.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::remove(boost::corosio::detail::kqueue_local_stream_socket*)
:115
68x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::remove(boost::corosio::detail::kqueue_tcp_acceptor*)
:115
996x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::remove(boost::corosio::detail::kqueue_tcp_socket*)
:115
13070x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::remove(boost::corosio::detail::kqueue_udp_socket*)
:115
91x
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*)
:115
150x
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*)
:115
43x
100.0%
–
57.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::remove(boost::corosio::detail::posix_resolver*)
:115
42x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::remove(boost::corosio::detail::posix_signal*)
:115
104x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::remove(boost::corosio::detail::posix_stream_file*)
:115
43x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::remove(boost::corosio::detail::select_local_datagram_socket*)
:115
63x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::remove(boost::corosio::detail::select_local_stream_acceptor*)
:115
22x
100.0%
–
57.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::remove(boost::corosio::detail::select_local_stream_socket*)
:115
68x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::remove(boost::corosio::detail::select_tcp_acceptor*)
:115
110x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::remove(boost::corosio::detail::select_tcp_socket*)
:115
4877x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::remove(boost::corosio::detail::select_udp_socket*)
:115
91x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::remove(boost::corosio::detail::waiter_node*)
:115
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*))
:135
122x
50.0%
25.0%
42.0%
<unknown function 173>
:173
–
–
–
–
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::intrusive_queue()
:177
2188x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::intrusive_queue()
:177
4888140x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::empty() const
:191
1242x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::empty() const
:191
9337614x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::push(boost::corosio::detail::pool_work_item*)
:196
217x
100.0%
50.0%
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::push(boost::corosio::detail::scheduler_op*)
:196
2833120x
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>&)
:206
1450397x
90.0%
75.0%
85.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::pop()
:219
2413x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::pop()
:219
4004081x
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 | 1197315x | T* head_ = nullptr; | ||
| 44 | 1197315x | T* tail_ = nullptr; | ||
| 45 | ||||
| 46 | public: | |||
| 47 | 3591945x | 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 | 31933x | void push_back(T* w) noexcept | ||
| 67 | { | |||
| 68 |
12/34✗ Branch 0 not taken.
✓ Branch 1 taken 5137 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13242 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 43 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 43 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 110 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 91 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 22 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 63 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 996 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 91 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 22 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 63 times.
|
31933x | auto* n = static_cast<node*>(w); | |
| 69 | 31933x | n->next_ = nullptr; | ||
| 70 | 31933x | n->prev_ = tail_; | ||
| 71 |
23/36✓ Branch 0 taken 4963 times.
✓ Branch 1 taken 12142 times.
✓ Branch 2 taken 12106 times.
✓ Branch 3 taken 1074 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 42 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 43 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 7 times.
✓ Branch 15 taken 103 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 67 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 22 times.
✓ Branch 22 taken 22 times.
✓ Branch 23 taken 41 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 987 times.
✓ Branch 28 taken 24 times.
✓ Branch 29 taken 67 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 22 times.
✓ Branch 34 taken 22 times.
✓ Branch 35 taken 41 times.
|
31933x | if (tail_) | |
| 72 |
11/38✗ Branch 0 not taken.
✗ Branch 0 not taken.
✓ Branch 1 taken 4915 times.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12105 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✗ 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 7 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 24 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 22 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 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 22 times.
|
17188x | static_cast<node*>(tail_)->next_ = w; | |
| 73 | else | |||
| 74 | 14745x | head_ = w; | ||
| 75 | 31933x | tail_ = w; | ||
| 76 | 31933x | } | ||
| 77 | ||||
| 78 | void splice_back(intrusive_list& other) noexcept | |||
| 79 | { | |||
| 80 | if (other.empty()) | |||
| 81 | return; | |||
| 82 | if (tail_) | |||
| 83 | { | |||
| 84 | static_cast<node*>(tail_)->next_ = other.head_; | |||
| 85 | static_cast<node*>(other.head_)->prev_ = tail_; | |||
| 86 | tail_ = other.tail_; | |||
| 87 | } | |||
| 88 | else | |||
| 89 | { | |||
| 90 | head_ = other.head_; | |||
| 91 | tail_ = other.tail_; | |||
| 92 | } | |||
| 93 | other.head_ = nullptr; | |||
| 94 | other.tail_ = nullptr; | |||
| 95 | } | |||
| 96 | ||||
| 97 | 1214854x | T* pop_front() noexcept | ||
| 98 | { | |||
| 99 |
18/34✓ Branch 0 taken 11974 times.
✓ Branch 1 taken 1191960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1092 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1092 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1092 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1092 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 429 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 429 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 429 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 429 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 429 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 429 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 663 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 663 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 663 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 663 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 663 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 663 times.
|
1214854x | if (!head_) | |
| 100 | 1202880x | return nullptr; | ||
| 101 | 11974x | T* w = head_; | ||
| 102 |
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.
|
11974x | head_ = static_cast<node*>(head_)->next_; | |
| 103 |
2/34✓ Branch 0 taken 46 times.
✓ Branch 1 taken 11928 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.
|
11974x | if (head_) | |
| 104 |
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.
|
46x | static_cast<node*>(head_)->prev_ = nullptr; | |
| 105 | else | |||
| 106 | 11928x | tail_ = nullptr; | ||
| 107 | // Defensive: clear stale linkage so remove() on a | |||
| 108 | // popped node cannot corrupt the list. | |||
| 109 |
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.
|
11974x | auto* n = static_cast<node*>(w); | |
| 110 | 11974x | n->next_ = nullptr; | ||
| 111 | 11974x | n->prev_ = nullptr; | ||
| 112 | 11974x | return w; | ||
| 113 | 1214854x | } | ||
| 114 | ||||
| 115 | 19959x | void remove(T* w) noexcept | ||
| 116 | { | |||
| 117 |
16/34✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 43 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 43 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4877 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 110 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 91 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 68 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 22 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 63 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 13070 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 996 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 91 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 68 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 22 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 63 times.
|
19959x | auto* n = static_cast<node*>(w); | |
| 118 | // Already detached — nothing to do. | |||
| 119 |
69/144✓ Branch 0 taken 63 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 63 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 104 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 94 times.
✓ Branch 19 taken 10 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 94 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 43 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 42 times.
✓ Branch 27 taken 1 time.
✗ Branch 28 not taken.
✓ Branch 29 taken 42 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 43 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 43 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✓ Branch 45 taken 43 times.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✓ Branch 48 taken 1665 times.
✓ Branch 49 taken 3212 times.
✓ Branch 50 taken 112 times.
✓ Branch 51 taken 1553 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 112 times.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 110 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 103 times.
✓ Branch 59 taken 7 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 103 times.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✓ Branch 64 taken 91 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 67 times.
✓ Branch 67 taken 24 times.
✗ Branch 68 not taken.
✓ Branch 69 taken 67 times.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 72 taken 56 times.
✓ Branch 73 taken 12 times.
✓ Branch 74 taken 39 times.
✓ Branch 75 taken 17 times.
✗ Branch 76 not taken.
✓ Branch 77 taken 39 times.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✓ Branch 80 taken 22 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 22 times.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✓ Branch 85 taken 22 times.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✓ Branch 88 taken 63 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 41 times.
✓ Branch 91 taken 22 times.
✗ Branch 92 not taken.
✓ Branch 93 taken 41 times.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✓ Branch 96 taken 4414 times.
✓ Branch 97 taken 8656 times.
✓ Branch 98 taken 994 times.
✓ Branch 99 taken 3420 times.
✗ Branch 100 not taken.
✓ Branch 101 taken 994 times.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 996 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 987 times.
✓ Branch 107 taken 9 times.
✗ Branch 108 not taken.
✓ Branch 109 taken 987 times.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✓ Branch 112 taken 91 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 67 times.
✓ Branch 115 taken 24 times.
✗ Branch 116 not taken.
✓ Branch 117 taken 67 times.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✓ Branch 120 taken 56 times.
✓ Branch 121 taken 12 times.
✓ Branch 122 taken 39 times.
✓ Branch 123 taken 17 times.
✗ Branch 124 not taken.
✓ Branch 125 taken 39 times.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✓ Branch 128 taken 22 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 22 times.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✓ Branch 133 taken 22 times.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✓ Branch 136 taken 63 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 41 times.
✓ Branch 139 taken 22 times.
✗ Branch 140 not taken.
✓ Branch 141 taken 41 times.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
|
19959x | if (!n->next_ && !n->prev_ && head_ != w && tail_ != w) | |
| 120 | ✗ | return; | ||
| 121 |
30/36✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 42 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 43 times.
✓ Branch 12 taken 1573 times.
✓ Branch 13 taken 3304 times.
✓ Branch 14 taken 7 times.
✓ Branch 15 taken 103 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 67 times.
✓ Branch 18 taken 17 times.
✓ Branch 19 taken 51 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 22 times.
✓ Branch 22 taken 22 times.
✓ Branch 23 taken 41 times.
✓ Branch 24 taken 3501 times.
✓ Branch 25 taken 9569 times.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 987 times.
✓ Branch 28 taken 24 times.
✓ Branch 29 taken 67 times.
✓ Branch 30 taken 17 times.
✓ Branch 31 taken 51 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 22 times.
✓ Branch 34 taken 22 times.
✓ Branch 35 taken 41 times.
|
19959x | if (n->prev_) | |
| 122 |
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 1 time.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1573 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 24 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 17 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 22 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 3501 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 9 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 17 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 22 times.
|
5228x | static_cast<node*>(n->prev_)->next_ = n->next_; | |
| 123 | else | |||
| 124 | 14731x | head_ = n->next_; | ||
| 125 |
22/36✓ Branch 0 taken 123 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 104 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 43 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 43 times.
✓ Branch 12 taken 3212 times.
✓ Branch 13 taken 1665 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 110 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 91 times.
✓ Branch 18 taken 12 times.
✓ Branch 19 taken 56 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 22 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 63 times.
✓ Branch 24 taken 8656 times.
✓ Branch 25 taken 4414 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 996 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 91 times.
✓ Branch 30 taken 12 times.
✓ Branch 31 taken 56 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 22 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 63 times.
|
19959x | if (n->next_) | |
| 126 |
5/36✗ Branch 0 not taken.
✗ Branch 0 not taken.
✓ Branch 1 taken 121 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 3212 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 12 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 8656 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 12 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
12015x | static_cast<node*>(n->next_)->prev_ = n->prev_; | |
| 127 | else | |||
| 128 | 7944x | tail_ = n->prev_; | ||
| 129 | 19959x | n->next_ = nullptr; | ||
| 130 | 19959x | n->prev_ = nullptr; | ||
| 131 | 19959x | } | ||
| 132 | ||||
| 133 | /// Invoke @p f for each element in the list. | |||
| 134 | template<class F> | |||
| 135 | 122x | void for_each(F f) | ||
| 136 | { | |||
| 137 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
122x | for (T* p = head_; p; p = static_cast<node*>(p)->next_) | |
| 138 | ✗ | f(p); | ||
| 139 | 122x | } | ||
| 140 | }; | |||
| 141 | ||||
| 142 | /** An intrusive singly linked FIFO queue. | |||
| 143 | ||||
| 144 | This container provides O(1) push and pop operations for | |||
| 145 | elements that derive from @ref node. Elements are not | |||
| 146 | copied or moved; they are linked directly into the queue. | |||
| 147 | ||||
| 148 | Unlike @ref intrusive_list, this uses only a single `next_` | |||
| 149 | pointer per node, saving memory at the cost of not supporting | |||
| 150 | O(1) removal of arbitrary elements. | |||
| 151 | ||||
| 152 | @tparam T The element type. Must derive from `intrusive_queue<T>::node`. | |||
| 153 | */ | |||
| 154 | template<class T> | |||
| 155 | class intrusive_queue | |||
| 156 | { | |||
| 157 | public: | |||
| 158 | /** Base class for queue elements. | |||
| 159 | ||||
| 160 | Derive from this class to make a type usable with | |||
| 161 | @ref intrusive_queue. The `next_` pointer is private | |||
| 162 | and accessible only to the queue. | |||
| 163 | */ | |||
| 164 | class node | |||
| 165 | { | |||
| 166 | friend class intrusive_queue; | |||
| 167 | ||||
| 168 | private: | |||
| 169 | T* next_; | |||
| 170 | }; | |||
| 171 | ||||
| 172 | private: | |||
| 173 | 2445164x | T* head_ = nullptr; | ||
| 174 | 2445164x | T* tail_ = nullptr; | ||
| 175 | ||||
| 176 | public: | |||
| 177 | 7335492x | intrusive_queue() = default; | ||
| 178 | ||||
| 179 | intrusive_queue(intrusive_queue&& other) noexcept | |||
| 180 | : head_(other.head_) | |||
| 181 | , tail_(other.tail_) | |||
| 182 | { | |||
| 183 | other.head_ = nullptr; | |||
| 184 | other.tail_ = nullptr; | |||
| 185 | } | |||
| 186 | ||||
| 187 | intrusive_queue(intrusive_queue const&) = delete; | |||
| 188 | intrusive_queue& operator=(intrusive_queue const&) = delete; | |||
| 189 | intrusive_queue& operator=(intrusive_queue&&) = delete; | |||
| 190 | ||||
| 191 | 9338856x | bool empty() const noexcept | ||
| 192 | { | |||
| 193 | 9338856x | return head_ == nullptr; | ||
| 194 | } | |||
| 195 | ||||
| 196 | 2833337x | void push(T* w) noexcept | ||
| 197 | { | |||
| 198 | 2833337x | w->next_ = nullptr; | ||
| 199 |
2/4✓ Branch 0 taken 1290264 times.
✓ Branch 1 taken 1543073 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2833337x | if (tail_) | |
| 200 | 1290264x | tail_->next_ = w; | ||
| 201 | else | |||
| 202 | 1543073x | head_ = w; | ||
| 203 | 2833337x | tail_ = w; | ||
| 204 | 2833337x | } | ||
| 205 | ||||
| 206 | 1450397x | void splice(intrusive_queue& other) noexcept | ||
| 207 | { | |||
| 208 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1450397 times.
|
1450397x | if (other.empty()) | |
| 209 | ✗ | return; | ||
| 210 |
2/2✓ Branch 0 taken 336733 times.
✓ Branch 1 taken 1113664 times.
|
1450397x | if (tail_) | |
| 211 | 336733x | tail_->next_ = other.head_; | ||
| 212 | else | |||
| 213 | 1113664x | head_ = other.head_; | ||
| 214 | 1450397x | tail_ = other.tail_; | ||
| 215 | 1450397x | other.head_ = nullptr; | ||
| 216 | 1450397x | other.tail_ = nullptr; | ||
| 217 | 1450397x | } | ||
| 218 | ||||
| 219 | 4006494x | T* pop() noexcept | ||
| 220 | { | |||
| 221 |
2/4✓ Branch 0 taken 2833337 times.
✓ Branch 1 taken 1173157 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4006494x | if (!head_) | |
| 222 | 1173157x | return nullptr; | ||
| 223 | 2833337x | T* w = head_; | ||
| 224 | 2833337x | head_ = head_->next_; | ||
| 225 |
2/4✓ Branch 0 taken 1626997 times.
✓ Branch 1 taken 1206340 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2833337x | if (!head_) | |
| 226 | 1206340x | tail_ = nullptr; | ||
| 227 | // Defensive: clear stale linkage on popped node. | |||
| 228 | 2833337x | w->next_ = nullptr; | ||
| 229 | 2833337x | return w; | ||
| 230 | 4006494x | } | ||
| 231 | }; | |||
| 232 | ||||
| 233 | } // namespace boost::corosio::detail | |||
| 234 | ||||
| 235 | #endif | |||
| 236 |