Commit b44d69b9 authored by Dominik Charousset's avatar Dominik Charousset Committed by Neverlord

removed channel::enqueue

this patch equalizes the interface of `channel` and `actor` by
removing the `enqueue` member function and providing `operator->`
instead to access the `enqueue` member function of the held pointer
directly
parent 64892301
......@@ -43,6 +43,7 @@ namespace cppa {
class actor;
class group;
class execution_unit;
struct invalid_actor_t;
struct invalid_group_t;
......@@ -87,8 +88,13 @@ class channel : util::comparable<channel>
return !m_ptr;
}
inline abstract_channel* operator->() const {
return m_ptr.get();
}
void enqueue(const message_header& hdr, any_tuple msg) const;
inline abstract_channel& operator*() const {
return *m_ptr;
}
intptr_t compare(const channel& other) const;
......
......@@ -438,7 +438,7 @@ namespace cppa {
* @brief Sends @p to a message under the identity of @p from.
*/
inline void send_tuple_as(const actor& from, const channel& to, any_tuple msg) {
to.enqueue({from.address(), to}, std::move(msg));
if (to) to->enqueue({from.address(), to}, std::move(msg));
}
/**
......
......@@ -142,9 +142,10 @@ void local_actor::forward_message(const actor& dest, message_priority p) {
}
void local_actor::send_tuple(message_priority prio, const channel& dest, any_tuple what) {
if (!dest) return;
message_id id;
if (prio == message_priority::high) id = id.with_high_priority();
dest.enqueue({address(), dest, id}, std::move(what));
dest->enqueue({address(), dest, id}, std::move(what));
}
void local_actor::send_exit(const actor_addr& whom, std::uint32_t reason) {
......
......@@ -38,18 +38,18 @@ message_header::message_header(actor_addr source,
message_id mid)
: sender(source), receiver(dest), id(mid) { }
bool operator==(const message_header& lhs, const message_header& rhs) {
bool operator==(msg_hdr_cref lhs, msg_hdr_cref rhs) {
return lhs.sender == rhs.sender
&& lhs.receiver == rhs.receiver
&& lhs.id == rhs.id;
}
bool operator!=(const message_header& lhs, const message_header& rhs) {
bool operator!=(msg_hdr_cref lhs, msg_hdr_cref rhs) {
return !(lhs == rhs);
}
void message_header::deliver(any_tuple msg) const {
receiver.enqueue(*this, std::move(msg));
if (receiver) receiver->enqueue(*this, std::move(msg));
}
} // namespace cppa::network
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment