Commit f0741ac5 authored by Jakob Otto's avatar Jakob Otto

Include review feedback

parent bd29f8b3
......@@ -27,12 +27,13 @@
namespace caf::net {
/// 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
/// `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 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,
class IdType>
class transport_base {
......@@ -62,28 +63,28 @@ public:
// -- properties -------------------------------------------------------------
/// @return the `socket_handle` of this transport.
/// Returns the socket_handle of this transport.
handle_type handle() const noexcept {
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.
actor_system& system() {
return manager().system();
}
/// @return reference to the `application` of this transport.
/// Returns a reference to the application of this transport.
application_type& application() {
return next_layer_.application();
}
/// @return reference to `this` transport.
/// Returns a reference to this transport.
transport_type& transport() {
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.
endpoint_manager& manager() {
CAF_ASSERT(manager_);
......@@ -93,8 +94,8 @@ public:
// -- transport member functions ---------------------------------------------
/// Initializes this transport.
/// @param parent the endpoint manager that manages this transport.
/// @return `error` on failure, none on success.
/// @param parent The endpoint manager that manages this transport.
/// @returns `error` on failure, none on success.
virtual error init(endpoint_manager& parent) {
CAF_LOG_TRACE("");
manager_ = &parent;
......@@ -110,10 +111,10 @@ public:
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.
/// @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) {
CAF_LOG_TRACE(CAF_ARG(locator) << CAF_ARG(listener));
auto f = detail::make_overload(
......@@ -127,7 +128,9 @@ public:
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) {
next_layer_.new_proxy(*this, peer, id);
}
......@@ -135,16 +138,16 @@ public:
/// Notifies the remote endpoint that the local actor is down.
/// @param peer The `node_id` of the remote endpoint.
/// @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,
error reason) {
next_layer_.local_actor_down(*this, peer, id, std::move(reason));
}
/// timeout callback for this transport. Will be called after a timeout is
/// triggered.
/// Notifies the transport that the timeout identified by `value` plus `id`
/// was triggered.
/// @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) {
next_layer_.timeout(*this, value, id);
}
......@@ -167,32 +170,34 @@ public:
// -- (pure) virtual functions -----------------------------------------------
/// Configures the next read_event.
virtual void configure_read(receive_policy::config){
/// Configures this transport for the next read event.
virtual void configure_read(receive_policy::config) {
// 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;
/// 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;
/// Moves a packet that is scattered across multiple buffers into the
/// write_queue of this transport.
/// @param id the endpoint id
/// @param buffers the packet scattered across multiple buffers.
/// Queues a packet scattered across multiple buffers to be sent via this
/// transport.
/// @param id The id of the destination endpoint.
/// @param buffers Pointers to the buffers that make up the packet content.
virtual void write_packet(id_type id, span<buffer_type*> buffers) = 0;
// -- 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.
buffer_type next_header_buffer() {
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.
buffer_type next_payload_buffer() {
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