QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSCancellation.h
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <memory>
5
6#include <QtCore/QtGlobal>
7
11{
12public:
14 GPSCancelToken() = default;
15
17 [[nodiscard]] bool isCancelled() const;
18
19private:
20 friend class GPSCancelSource;
21 friend class GPSCancelCallback;
22
23 struct State;
24
25 explicit GPSCancelToken(std::shared_ptr<State> state);
26
27 std::shared_ptr<State> _state;
28};
29
32{
33public:
35
36 [[nodiscard]] GPSCancelToken token() const;
37
40 bool cancel();
41
42 [[nodiscard]] bool isCancelled() const;
43
44private:
45 std::shared_ptr<GPSCancelToken::State> _state;
46};
47
52{
53public:
54 GPSCancelCallback(const GPSCancelToken& token, std::function<void()> callback);
56
57 Q_DISABLE_COPY(GPSCancelCallback)
58
59private:
60 std::shared_ptr<GPSCancelToken::State> _state;
61 std::function<void()> _callback;
62};
Issues tokens and cancels them all at once. Copies share the cancellation.
bool isCancelled() const
GPSCancelToken token() const
bool isCancelled() const
Safe to call from any thread.
GPSCancelToken()=default
A token that is never cancelled.