rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
address.hpp
1#pragma once
2
3//
4// Copyright (c) 2019-2022 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
5//
6// Distributed under the MIT Software License
7//
8
9#include "arc.hpp"
10#include "forward.hpp"
11
12namespace rotor {
13
33struct address_t : public arc_base_t<address_t> {
36
38 const void *locality;
39
40 address_t(const address_t &) = delete;
41 address_t(address_t &&) = delete;
42
46 inline bool operator==(const address_t &other) const noexcept { return this == &other; }
47
49 inline bool same_locality(const address_t &other) const noexcept { return this->locality == other.locality; }
50
51 private:
52 friend struct supervisor_t;
53 address_t(supervisor_t &sup, const void *locality_) : supervisor{sup}, locality{locality_} {}
54};
55
58
59} // namespace rotor
60
61namespace std {
65template <> struct hash<rotor::address_ptr_t> {
67 inline size_t operator()(const rotor::address_ptr_t &address) const noexcept {
68 return reinterpret_cast<size_t>(address.get());
69 }
70};
71
72} // namespace std
Basic namespace for all rotor functionalities.
Definition rotor.hpp:21
intrusive_ptr_t< address_t > address_ptr_t
intrusive pointer for address
Definition address.hpp:57
boost::intrusive_ref_counter< T, counter_policy_t > arc_base_t
base class to inject ref-counter with the specified policy
Definition arc.hpp:24
boost::intrusive_ptr< T > intrusive_ptr_t
alias for intrusive pointer
Definition arc.hpp:27
Message subscription and delivery point.
Definition address.hpp:33
const void * locality
runtime label, describing some execution group
Definition address.hpp:38
bool operator==(const address_t &other) const noexcept
returns true if two addresses are the same, i.e. are located in the same memory region
Definition address.hpp:46
bool same_locality(const address_t &other) const noexcept
compares locality fields of the addresses
Definition address.hpp:49
supervisor_t & supervisor
reference to supervisor_t, which generated the address
Definition address.hpp:35
supervisor is responsible for managing actors (workers) lifetime
Definition supervisor.h:69