Browse Source

cleaned up dispatcher's internal handling of dispatching tasks to platform-sdk

QGC4.4
jennerl 4 years ago committed by Don Gagne
parent
commit
c44b9d65e5
  1. 2
      src/Airmap/qt/client.h
  2. 16
      src/Airmap/qt/dispatcher.cpp
  3. 9
      src/Airmap/qt/dispatcher.h

2
src/Airmap/qt/client.h

@ -16,7 +16,7 @@ namespace airmap { @@ -16,7 +16,7 @@ namespace airmap {
namespace qt {
/// Client implements the airmap::Client interface, bridging over between
/// the Qt event loop and the native event loop of the native airmap::Client.
/// the Qt event loop and the native event loop of the airmap::Client.
///
/// All callback invocations that might happen in the context of a Client instance
/// are dispatched to the Qt applications' main thread.

16
src/Airmap/qt/dispatcher.cpp

@ -47,20 +47,8 @@ bool airmap::qt::Dispatcher::ToQt::event(QEvent* event) { @@ -47,20 +47,8 @@ bool airmap::qt::Dispatcher::ToQt::event(QEvent* event) {
return false;
}
std::shared_ptr<airmap::qt::Dispatcher::ToNative> airmap::qt::Dispatcher::ToNative::create(
const std::shared_ptr<Context>& context) {
return std::shared_ptr<ToNative>{new ToNative{context}};
}
airmap::qt::Dispatcher::ToNative::ToNative(const std::shared_ptr<Context>& context) : context_{context} {
}
void airmap::qt::Dispatcher::ToNative::dispatch(const Task& task) {
context_->schedule_in(task);
}
airmap::qt::Dispatcher::Dispatcher(const std::shared_ptr<Context>& context)
: to_qt_{ToQt::create()}, to_native_{ToNative::create(context)} {
: to_qt_{ToQt::create()}, context_{context} {
}
void airmap::qt::Dispatcher::dispatch_to_qt(const std::function<void()>& task) {
@ -68,7 +56,7 @@ void airmap::qt::Dispatcher::dispatch_to_qt(const std::function<void()>& task) { @@ -68,7 +56,7 @@ void airmap::qt::Dispatcher::dispatch_to_qt(const std::function<void()>& task) {
}
void airmap::qt::Dispatcher::dispatch_to_airmap(const std::function<void()>& task) {
to_native_->dispatch(task);
context_->schedule_in(task);
}
// From QObject

9
src/Airmap/qt/dispatcher.h

@ -37,14 +37,13 @@ class Dispatcher : public QObject { @@ -37,14 +37,13 @@ class Dispatcher : public QObject {
bool event(QEvent* event) override;
};
class ToNative : public std::enable_shared_from_this<ToNative> {
class ToAirmap : public std::enable_shared_from_this<ToAirmap> {
public:
static std::shared_ptr<ToNative> create(const std::shared_ptr<Context>& context);
static std::shared_ptr<ToAirmap> create(const std::shared_ptr<Context>& context);
void dispatch(const Task& task);
private:
explicit ToNative(const std::shared_ptr<Context>& context);
std::shared_ptr<Context> context_;
explicit ToAirmap(const std::shared_ptr<Context>& context);
};
explicit Dispatcher(const std::shared_ptr<Context>& context);
@ -54,7 +53,7 @@ class Dispatcher : public QObject { @@ -54,7 +53,7 @@ class Dispatcher : public QObject {
private:
std::shared_ptr<ToQt> to_qt_;
std::shared_ptr<ToNative> to_native_;
std::shared_ptr<Context> context_;
};
} // namespace qt

Loading…
Cancel
Save