Commit f0741ac5 authored by Jakob Otto's avatar Jakob Otto

Include review feedback

parent bd29f8b3
...@@ -27,12 +27,13 @@ ...@@ -27,12 +27,13 @@
namespace caf::net { namespace caf::net {
/// Implements base class for transports. /// Implements base class for transports.
/// @tparam Transport The actual type of the implementin transport. /// @tparam Transport The derived type of the transport implementation.
/// @tparam NextLayer The Following Layer. Either `transport_worker` or /// @tparam NextLayer The Following Layer. Either `transport_worker` or
/// `transport_worker_dispatcher` /// `transport_worker_dispatcher`
/// @tparam Handle The type of the used socket_handle /// @tparam Handle The type of the related socket_handle.
/// @tparam Application The type of the application used in this stack. /// @tparam Application The type of the application used in this stack.
/// @tparam IdType The type of the Id used by this transport. /// @tparam IdType The id type of the derived transport, must match the IdType
/// of `NextLayer`.
template <class Transport, class NextLayer, class Handle, class Application, template <class Transport, class NextLayer, class Handle, class Application,
class IdType> class IdType>
class transport_base { class transport_base {
...@@ -62,28 +63,28 @@ public: ...@@ -62,28 +63,28 @@ public:
// -- properties ------------------------------------------------------------- // -- properties -------------------------------------------------------------
/// @return the `socket_handle` of this transport. /// Returns the socket_handle of this transport.
handle_type handle() const noexcept { handle_type handle() const noexcept {
return handle_; return handle_;
} }
/// @return reference to the `actor_system` of this transport. /// Returns a reference to the actor_system of this transport.
/// @pre `init` must be called before calling this getter. /// @pre `init` must be called before calling this getter.
actor_system& system() { actor_system& system() {
return manager().system(); return manager().system();
} }
/// @return reference to the `application` of this transport. /// Returns a reference to the application of this transport.
application_type& application() { application_type& application() {
return next_layer_.application(); return next_layer_.application();
} }
/// @return reference to `this` transport. /// Returns a reference to this transport.
transport_type& transport() { transport_type& transport() {
return *reinterpret_cast<transport_type*>(this); return *reinterpret_cast<transport_type*>(this);
} }
/// @return reference to the `endpoint_manager` of this transport. /// Returns a reference to the endpoint_manager of this transport.
/// @pre `init` must be called before calling this getter. /// @pre `init` must be called before calling this getter.
endpoint_manager& manager() { endpoint_manager& manager() {
CAF_ASSERT(manager_); CAF_ASSERT(manager_);
...@@ -93,8 +94,8 @@ public: ...@@ -93,8 +94,8 @@ public:
// -- transport member functions --------------------------------------------- // -- transport member functions ---------------------------------------------
/// Initializes this transport. /// Initializes this transport.
/// @param parent the endpoint manager that manages this transport. /// @param parent The endpoint manager that manages this transport.
/// @return `error` on failure, none on success. /// @returns `error` on failure, none on success.
virtual error init(endpoint_manager& parent) { virtual error init(endpoint_manager& parent) {
CAF_LOG_TRACE(""); CAF_LOG_TRACE("");
manager_ = &parent; manager_ = &parent;
...@@ -110,10 +111,10 @@ public: ...@@ -110,10 +111,10 @@ public:
return none; return none;
} }
/// Resolves a remote actor using 'locator' and sends the resolved actor to /// Resolves a remote actor using `locator` and sends the resolved actor to
/// listener on success - an error otherwise. /// listener on success - an error otherwise.
/// @param locator The `uri` of the remote actor. /// @param locator The `uri` of the remote actor.
/// @param listener actor_handle which the resolved actor should be sent to. /// @param listener The `actor_handle` which the result should be sent to.
auto resolve(endpoint_manager&, const uri& locator, const actor& listener) { auto resolve(endpoint_manager&, const uri& locator, const actor& listener) {
CAF_LOG_TRACE(CAF_ARG(locator) << CAF_ARG(listener)); CAF_LOG_TRACE(CAF_ARG(locator) << CAF_ARG(listener));
auto f = detail::make_overload( auto f = detail::make_overload(
...@@ -127,7 +128,9 @@ public: ...@@ -127,7 +128,9 @@ public:
f(next_layer_); f(next_layer_);
} }
/// /// Gets called by actor_proxy after creation.
/// @param peer the node_id of the remote node.
/// @param id the id of the remote actor.
void new_proxy(endpoint_manager&, const node_id& peer, actor_id id) { void new_proxy(endpoint_manager&, const node_id& peer, actor_id id) {
next_layer_.new_proxy(*this, peer, id); next_layer_.new_proxy(*this, peer, id);
} }
...@@ -135,16 +138,16 @@ public: ...@@ -135,16 +138,16 @@ public:
/// Notifies the remote endpoint that the local actor is down. /// Notifies the remote endpoint that the local actor is down.
/// @param peer The `node_id` of the remote endpoint. /// @param peer The `node_id` of the remote endpoint.
/// @param id The `actor_id` of the remote actor. /// @param id The `actor_id` of the remote actor.
/// @param reason The reason why the local actor has shut_down. /// @param reason The reason why the local actor has shut down.
void local_actor_down(endpoint_manager&, const node_id& peer, actor_id id, void local_actor_down(endpoint_manager&, const node_id& peer, actor_id id,
error reason) { error reason) {
next_layer_.local_actor_down(*this, peer, id, std::move(reason)); next_layer_.local_actor_down(*this, peer, id, std::move(reason));
} }
/// timeout callback for this transport. Will be called after a timeout is /// Notifies the transport that the timeout identified by `value` plus `id`
/// triggered. /// was triggered.
/// @param value The `atom_value` of the timeout. /// @param value The `atom_value` of the timeout.
/// @param id The timeout id of this timeout. /// @param id The timeout id of the timeout.
void timeout(endpoint_manager&, atom_value value, uint64_t id) { void timeout(endpoint_manager&, atom_value value, uint64_t id) {
next_layer_.timeout(*this, value, id); next_layer_.timeout(*this, value, id);
} }
...@@ -167,32 +170,34 @@ public: ...@@ -167,32 +170,34 @@ public:
// -- (pure) virtual functions ----------------------------------------------- // -- (pure) virtual functions -----------------------------------------------
/// Configures the next read_event. /// Configures this transport for the next read event.
virtual void configure_read(receive_policy::config){ virtual void configure_read(receive_policy::config) {
// nop // nop
}; }
/// Callback when a read_event occurs. /// Called by the endpoint manager when the transport can read data from its
/// socket.
virtual bool handle_read_event(endpoint_manager&) = 0; virtual bool handle_read_event(endpoint_manager&) = 0;
/// Callback when a write_event occurs. /// Called by the endpoint manager when the transport can write data to its
/// socket.
virtual bool handle_write_event(endpoint_manager& parent) = 0; virtual bool handle_write_event(endpoint_manager& parent) = 0;
/// Moves a packet that is scattered across multiple buffers into the /// Queues a packet scattered across multiple buffers to be sent via this
/// write_queue of this transport. /// transport.
/// @param id the endpoint id /// @param id The id of the destination endpoint.
/// @param buffers the packet scattered across multiple buffers. /// @param buffers Pointers to the buffers that make up the packet content.
virtual void write_packet(id_type id, span<buffer_type*> buffers) = 0; virtual void write_packet(id_type id, span<buffer_type*> buffers) = 0;
// -- buffer management ------------------------------------------------------ // -- buffer management ------------------------------------------------------
/// Returns the next cached header_buffer or creates a new one if no buffers /// Returns the next cached header buffer or creates a new one if no buffers
/// are cached. /// are cached.
buffer_type next_header_buffer() { buffer_type next_header_buffer() {
return next_buffer_impl(header_bufs_); return next_buffer_impl(header_bufs_);
} }
/// Returns the next cached payload_buffer or creates a new one if no buffers /// Returns the next cached payload buffer or creates a new one if no buffers
/// are cached. /// are cached.
buffer_type next_payload_buffer() { buffer_type next_payload_buffer() {
return next_buffer_impl(payload_bufs_); return next_buffer_impl(payload_bufs_);
......
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