Commit aef6f0a4 authored by neverlord's avatar neverlord Committed by Dominik Charousset

Remove `invalid_connection_handle`

parent 478f539d
...@@ -29,23 +29,20 @@ namespace io { ...@@ -29,23 +29,20 @@ namespace io {
* Generic handle type for identifying connections. * Generic handle type for identifying connections.
*/ */
class connection_handle : public handle<connection_handle> { class connection_handle : public handle<connection_handle> {
public:
friend class handle<connection_handle>; friend class handle<connection_handle>;
using super = handle<connection_handle>; using super = handle<connection_handle>;
public: constexpr connection_handle() {
// nop
constexpr connection_handle() {} }
private: private:
inline connection_handle(int64_t handle_id) : super{handle_id} {
inline connection_handle(int64_t handle_id) : super{handle_id} {} // nop
}
}; };
constexpr connection_handle invalid_connection_handle = connection_handle{};
} // namespace io } // namespace io
} // namespace caf } // namespace caf
......
...@@ -36,7 +36,9 @@ class handle : detail::comparable<Subtype> { ...@@ -36,7 +36,9 @@ class handle : detail::comparable<Subtype> {
// nop // nop
} }
handle(const Subtype& other) { m_id = other.id(); } handle(const Subtype& other) {
m_id = other.id();
}
handle(const handle& other) = default; handle(const handle& other) = default;
...@@ -48,25 +50,37 @@ class handle : detail::comparable<Subtype> { ...@@ -48,25 +50,37 @@ class handle : detail::comparable<Subtype> {
/** /**
* Returns the unique identifier of this handle. * Returns the unique identifier of this handle.
*/ */
inline int64_t id() const { return m_id; } int64_t id() const {
return m_id;
}
/** /**
* Sets the unique identifier of this handle. * Sets the unique identifier of this handle.
*/ */
inline void set_id(int64_t value) { m_id = value; } void set_id(int64_t value) {
m_id = value;
}
inline int64_t compare(const Subtype& other) const { int64_t compare(const Subtype& other) const {
return m_id - other.id(); return m_id - other.id();
} }
inline bool invalid() const { return m_id == -1; } bool invalid() const {
return m_id == InvalidId;
}
void set_invalid() {
set_id(InvalidId);
}
static inline Subtype from_int(int64_t id) { static Subtype from_int(int64_t id) {
return {id}; return {id};
} }
protected: protected:
inline handle(int64_t handle_id) : m_id{handle_id} {} handle(int64_t handle_id) : m_id{handle_id} {
// nop
}
private: private:
int64_t m_id; int64_t m_id;
......
...@@ -74,7 +74,7 @@ behavior basp_broker::make_behavior() { ...@@ -74,7 +74,7 @@ behavior basp_broker::make_behavior() {
auto& entry = kvp.second; auto& entry = kvp.second;
if (entry.first.hdl == msg.handle) { if (entry.first.hdl == msg.handle) {
CAF_LOG_DEBUG("lost direct connection to " << to_string(kvp.first)); CAF_LOG_DEBUG("lost direct connection to " << to_string(kvp.first));
entry.first.hdl = invalid_connection_handle; entry.first.hdl.set_invalid();
} }
auto last = entry.second.end(); auto last = entry.second.end();
auto i = std::lower_bound(entry.second.begin(), last, msg.handle, auto i = std::lower_bound(entry.second.begin(), last, msg.handle,
......
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