MapLibre Native Core
aspiring_actor.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
mbgl/actor/mailbox.hpp
>
4
#include <
mbgl/actor/message.hpp
>
5
#include <
mbgl/actor/actor_ref.hpp
>
6
7
#include <memory>
8
#include <future>
9
#include <type_traits>
10
#include <cassert>
11
12
namespace
mbgl
{
13
14
template
<
class
Object>
15
class
EstablishedActor;
16
17
template
<
class
Object>
18
class
Actor;
19
34
template
<
class
Object>
35
class
AspiringActor
{
36
public
:
37
AspiringActor
() : mailbox(
std
::make_shared<
Mailbox
>()) {
38
// mailbox starts closed because the `Object` hasn't yet been constructed
39
assert(!mailbox->isOpen());
40
}
41
42
AspiringActor
(
const
AspiringActor
&) =
delete
;
43
44
ActorRef<std::decay_t<Object>
>
self
() {
45
return
ActorRef<std::decay_t<Object>
>(object(), mailbox);
46
}
47
48
private
:
49
std::shared_ptr<Mailbox> mailbox;
50
std::aligned_storage_t<
sizeof
(
Object
)> objectStorage;
51
52
Object
& object() {
53
return
*
reinterpret_cast<
Object
*
>
(&objectStorage);
54
}
55
56
friend
class
EstablishedActor
<
Object
>;
57
friend
class
Actor
<
Object
>;
58
};
59
60
}
// namespace mbgl
actor_ref.hpp
mbgl::ActorRef
Definition:
actor_ref.hpp:23
mbgl::Actor
Definition:
actor.hpp:52
mbgl::AspiringActor
Definition:
aspiring_actor.hpp:35
mbgl::AspiringActor::AspiringActor
AspiringActor()
Definition:
aspiring_actor.hpp:37
mbgl::AspiringActor::AspiringActor
AspiringActor(const AspiringActor &)=delete
mbgl::EstablishedActor
Definition:
established_actor.hpp:27
mbgl::Mailbox
Definition:
mailbox.hpp:15
mailbox.hpp
message.hpp
mbgl::style::expression::type::Object
constexpr ObjectType Object
Definition:
type.hpp:89
mbgl
Definition:
actor.hpp:15
std
Definition:
tile_id.hpp:256
include
mbgl
actor
aspiring_actor.hpp
MapLibre website
|
GitHub repository