• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mavlink / MAVSDK / 22127126125

18 Feb 2026 04:54AM UTC coverage: 48.964% (-0.05%) from 49.009%
22127126125

Pull #2769

github

web-flow
Merge e391237ec into 72946bd67
Pull Request #2769: core: add set_callback_executor API for custom callback dispatch

10 of 42 new or added lines in 3 files covered. (23.81%)

5 existing lines in 3 files now uncovered.

18353 of 37483 relevant lines covered (48.96%)

671.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.64
/cpp/src/mavsdk/core/locked_queue.h
1
#pragma once
2

3
#include <queue>
4
#include <mutex>
5
#include <memory>
6
#include <condition_variable>
7

8
namespace mavsdk {
9

10
template<class T> class LockedQueue {
11
public:
12
    LockedQueue() = default;
1,207✔
13
    ~LockedQueue() = default;
1,207✔
14

15
    void push_back(std::shared_ptr<T> item_ptr)
1,921✔
16
    {
17
        std::lock_guard<std::mutex> lock(_mutex);
1,921✔
18
        _queue.push_back(item_ptr);
1,921✔
19
        _condition_var.notify_one();
1,921✔
20
    }
1,920✔
21

22
    size_t size()
1,269✔
23
    {
24
        std::lock_guard<std::mutex> lock(_mutex);
1,269✔
25
        return _queue.size();
1,269✔
26
    }
1,269✔
27

28
    void stop()
303✔
29
    {
30
        std::lock_guard<std::mutex> lock(_mutex);
303✔
31
        _should_exit = true;
303✔
32
        _condition_var.notify_all();
303✔
33
    }
303✔
34

NEW
35
    void restart()
×
36
    {
NEW
37
        std::lock_guard<std::mutex> lock(_mutex);
×
NEW
38
        _should_exit = false;
×
NEW
39
    }
×
40

41
    using iterator = typename std::deque<std::shared_ptr<T>>::iterator;
42
    iterator begin() { return _queue.begin(); }
21,571✔
43

44
    iterator end() { return _queue.end(); }
21,640✔
45

46
    iterator erase(iterator it) { return _queue.erase(it); }
240✔
47

48
    // This guard serves the purpose to combine a get_front with a pop_front.
49
    // Thus, no one can interfere between the two steps.
50
    class Guard {
51
    public:
52
        explicit Guard(LockedQueue& locked_queue) :
145,374✔
53
            _locked_queue(locked_queue),
145,374✔
54
            _lock(locked_queue._mutex)
145,374✔
55
        {}
145,698✔
56

57
        ~Guard() = default;
148,312✔
58

59
        Guard(Guard& other) = delete;
60
        Guard(const Guard& other) = delete;
61
        Guard(Guard&& other) = delete;
62
        Guard(const Guard&& other) = delete;
63
        Guard& operator=(const Guard& other) = delete;
64
        Guard& operator=(Guard&& other) = delete;
65

66
        std::shared_ptr<T> get_front()
125,864✔
67
        {
68
            if (_locked_queue._queue.size() == 0) {
125,864✔
69
                return nullptr;
115,503✔
70
            }
71
            return _locked_queue._queue.front();
6,318✔
72
        }
73

74
        std::shared_ptr<T> wait_and_pop_front()
1,571✔
75
        {
76
            while (_locked_queue._queue.empty()) {
3,044✔
77
                if (_locked_queue._should_exit) {
1,776✔
78
                    return std::shared_ptr<T>{};
303✔
79
                }
80
                _locked_queue._condition_var.wait(_lock);
1,473✔
81
            }
82
            if (_locked_queue._should_exit) {
1,268✔
83
                return std::shared_ptr<T>{};
×
84
            }
85

86
            auto result = _locked_queue._queue.front();
1,268✔
87
            _locked_queue._queue.pop_front();
1,268✔
88
            return result;
1,268✔
89
        }
1,268✔
90

91
        void pop_front() { _locked_queue._queue.pop_front(); }
380✔
92

93
    private:
94
        LockedQueue<T>& _locked_queue;
95
        std::unique_lock<std::mutex> _lock;
96
    };
97

98
private:
99
    std::deque<std::shared_ptr<T>> _queue{};
100
    std::mutex _mutex{};
101
    std::condition_variable _condition_var{};
102
    bool _should_exit{false};
103
};
104

105
} // namespace mavsdk
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc