[core] Move mbgl::Pass and mbgl::PassRefPtr to a separate header

This commit is contained in:
Mikhail Pozdnyakov
2020-02-25 19:24:16 +02:00
parent ff6c1426e8
commit 1399040087
3 changed files with 27 additions and 17 deletions

View File

@@ -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

View File

@@ -1,5 +1,7 @@
#pragma once
#include <mbgl/util/pass_types.hpp>
#include <mapbox/weak.hpp>
#include <functional>
@@ -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 <typename T>
class Pass {
public:
Pass(T&& obj_) : obj(std::forward<T>(obj_)) {}
Pass(Pass&&) = default;
Pass(const Pass&) = delete;
operator T() && { return std::move(obj); }
private:
T obj;
};
template <typename T>
using PassRefPtr = Pass<std::shared_ptr<T>>;
/*
A `Scheduler` is responsible for coordinating the processing of messages by
one or more actors via their mailboxes. It's an abstract interface. Currently,

View File

@@ -0,0 +1,24 @@
#pragma once
#include <memory>
namespace mbgl {
// Using this type as a return type enforces the client to retain the returned object.
template <typename T>
class Pass {
public:
Pass(T&& obj_) : obj(std::forward<T>(obj_)) {}
Pass(Pass&&) noexcept = default;
Pass(const Pass&) = delete;
Pass& operator=(const Pass&) = delete;
operator T() && { return std::move(obj); }
private:
T obj;
};
template <typename T>
using PassRefPtr = Pass<std::shared_ptr<T>>;
} // namespace mbgl