Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
actor-incubator
Commits
f0741ac5
Commit
f0741ac5
authored
Nov 19, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include review feedback
parent
bd29f8b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
28 deletions
+33
-28
libcaf_net/caf/net/transport_base.hpp
libcaf_net/caf/net/transport_base.hpp
+33
-28
No files found.
libcaf_net/caf/net/transport_base.hpp
View file @
f0741ac5
...
...
@@ -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
t
he endpoint manager that manages this transport.
/// @return `error` on failure, none on success.
/// @param parent
T
he endpoint manager that manages this transport.
/// @return
s
`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 th
is
timeout.
/// @param id The timeout id of th
e
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 th
e next read_
event.
virtual
void
configure_read
(
receive_policy
::
config
){
/// Configures th
is 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_
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment