From 1399040087f9d0b6f2a836fc5e6468c938ebf99b Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Tue, 25 Feb 2020 19:24:16 +0200 Subject: [PATCH] [core] Move mbgl::Pass and mbgl::PassRefPtr to a separate header --- CMakeLists.txt | 1 + include/mbgl/actor/scheduler.hpp | 19 ++----------------- include/mbgl/util/pass_types.hpp | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 include/mbgl/util/pass_types.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d1490aea..0a09f0966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,6 +266,7 @@ add_library( ${PROJECT_SOURCE_DIR}/include/mbgl/util/logging.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/util/noncopyable.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/util/optional.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/util/pass_types.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/util/platform.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/util/premultiply.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/util/projection.hpp diff --git a/include/mbgl/actor/scheduler.hpp b/include/mbgl/actor/scheduler.hpp index d7fec41ea..dca6b132f 100644 --- a/include/mbgl/actor/scheduler.hpp +++ b/include/mbgl/actor/scheduler.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include @@ -9,23 +11,6 @@ namespace mbgl { class Mailbox; -// Using this type as a return type enforces the client to retain the returned object. -// TODO: Move to a separate file if/when other clients for this aux API turn up. -template -class Pass { -public: - Pass(T&& obj_) : obj(std::forward(obj_)) {} - Pass(Pass&&) = default; - Pass(const Pass&) = delete; - operator T() && { return std::move(obj); } - -private: - T obj; -}; - -template -using PassRefPtr = Pass>; - /* A `Scheduler` is responsible for coordinating the processing of messages by one or more actors via their mailboxes. It's an abstract interface. Currently, diff --git a/include/mbgl/util/pass_types.hpp b/include/mbgl/util/pass_types.hpp new file mode 100644 index 000000000..5415a3177 --- /dev/null +++ b/include/mbgl/util/pass_types.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include + +namespace mbgl { + +// Using this type as a return type enforces the client to retain the returned object. +template +class Pass { +public: + Pass(T&& obj_) : obj(std::forward(obj_)) {} + Pass(Pass&&) noexcept = default; + Pass(const Pass&) = delete; + Pass& operator=(const Pass&) = delete; + operator T() && { return std::move(obj); } + +private: + T obj; +}; + +template +using PassRefPtr = Pass>; + +} // namespace mbgl \ No newline at end of file