Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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 Framework
Commits
abbd084f
Commit
abbd084f
authored
Oct 22, 2016
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add datagram functionality to default multiplexer
parent
48b6303a
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
254 additions
and
39 deletions
+254
-39
libcaf_io/caf/io/abstract_broker.hpp
libcaf_io/caf/io/abstract_broker.hpp
+2
-2
libcaf_io/caf/io/datagram_source.hpp
libcaf_io/caf/io/datagram_source.hpp
+1
-3
libcaf_io/caf/io/network/default_multiplexer.hpp
libcaf_io/caf/io/network/default_multiplexer.hpp
+22
-13
libcaf_io/src/abstract_broker.cpp
libcaf_io/src/abstract_broker.cpp
+46
-0
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+183
-21
No files found.
libcaf_io/caf/io/abstract_broker.hpp
View file @
abbd084f
...
...
@@ -209,7 +209,7 @@ public:
/// Assigns a detached `datagram_sink` instance identified by `hdl`
/// from the `multiplexer` to this broker.
expected
<
void
>
assign_datagram_sink
(
connection
_handle
hdl
);
expected
<
void
>
assign_datagram_sink
(
datagram_sink
_handle
hdl
);
/// Creates and assigns a new `datagram_sink` from given native socked `fd`.
expected
<
datagram_sink_handle
>
add_datagram_sink
(
network
::
native_socket
fd
);
...
...
@@ -227,7 +227,7 @@ public:
/// Assigns a detached `datagram_source` instance identified by `hdl`
/// from the `multiplexer` to this broker.
expected
<
void
>
assign_datagram_source
(
accept
_handle
hdl
);
expected
<
void
>
assign_datagram_source
(
datagram_source
_handle
hdl
);
/// Creates and assigns a new `datagram_source` from given native socked `fd`.
expected
<
datagram_source_handle
>
...
...
libcaf_io/caf/io/datagram_source.hpp
View file @
abbd084f
...
...
@@ -44,10 +44,8 @@ public:
~
datagram_source
();
/*
/// Implicitly starts the read loop on first call.
virtual void configure_read(receive_policy::config config) = 0;
*/
virtual
void
configure_datagram_size
(
size_t
buf_size
)
=
0
;
/// Returns the current input buffer.
virtual
std
::
vector
<
char
>&
rd_buf
()
=
0
;
...
...
libcaf_io/caf/io/network/default_multiplexer.hpp
View file @
abbd084f
...
...
@@ -532,13 +532,6 @@ private:
native_socket
sock_
;
};
expected
<
native_socket
>
new_tcp_connection
(
const
std
::
string
&
host
,
uint16_t
port
,
optional
<
protocol
>
preferred
=
none
);
expected
<
std
::
pair
<
native_socket
,
uint16_t
>>
new_tcp_acceptor_impl
(
uint16_t
port
,
const
char
*
addr
,
bool
reuse_addr
);
/// A datagram_sender is responsible for sending datagrams to an endpoint.
class
datagram_sender
:
public
event_handler
{
public:
...
...
@@ -591,8 +584,6 @@ private:
manager_ptr
writer_
;
bool
ack_writes_
;
bool
writing_
;
size_t
written_
;
buffer_type
wr_buf_
;
buffer_type
wr_offline_buf_
;
};
...
...
@@ -612,6 +603,11 @@ public:
datagram_receiver
(
default_multiplexer
&
backend_ref
,
native_socket
sockfd
);
/// Configures how much buffer will be provided for the next datagram.
/// @warning Must not be called outside the IO multiplexers event loop
/// once the stream has been started.
void
configure_datagram_size
(
size_t
buf_size
);
/// Returns the read buffer of this datagram receiver.
/// @warning Must not be modified outside the IO multiplexers event loop
/// once the stream has been started.
...
...
@@ -634,14 +630,27 @@ public:
void
handle_event
(
operation
op
)
override
;
private:
void
prepare_next_read
();
manager_ptr
reader_
;
size_t
read_threshold_
;
size_t
collected_
;
size_t
max_
;
size_t
buf_size_
;
size_t
packet_size_
;
buffer_type
rd_buf_
;
struct
sockaddr_storage
last_sender
;
socklen_t
sender_len
;
};
expected
<
native_socket
>
new_tcp_connection
(
const
std
::
string
&
host
,
uint16_t
port
,
optional
<
protocol
>
preferred
=
none
);
expected
<
std
::
pair
<
native_socket
,
uint16_t
>>
new_tcp_acceptor_impl
(
uint16_t
port
,
const
char
*
addr
,
bool
reuse_addr
);
expected
<
native_socket
>
new_datagram_sink_impl
(
const
std
::
string
&
host
,
uint16_t
port
,
optional
<
protocol
>
preferred
=
none
);
}
// namespace network
}
// namespace io
}
// namespace caf
...
...
libcaf_io/src/abstract_broker.cpp
View file @
abbd084f
...
...
@@ -164,6 +164,52 @@ abstract_broker::add_tcp_doorman(network::native_socket fd) {
return
backend
().
add_tcp_doorman
(
this
,
fd
);
}
void
abstract_broker
::
add_datagram_sink
(
const
intrusive_ptr
<
datagram_sink
>&
ptr
)
{
datagram_sinks_
.
emplace
(
ptr
->
hdl
(),
ptr
);
}
expected
<
datagram_sink_handle
>
abstract_broker
::
add_datagram_sink
(
const
std
::
string
&
hostname
,
uint16_t
port
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hostname
)
<<
CAF_ARG
(
port
));
return
backend
().
add_datagram_sink
(
this
,
hostname
,
port
);
}
expected
<
void
>
abstract_broker
::
assign_datagram_sink
(
datagram_sink_handle
hdl
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
));
return
backend
().
assign_datagram_sink
(
this
,
hdl
);
}
expected
<
datagram_sink_handle
>
abstract_broker
::
add_datagram_sink
(
network
::
native_socket
fd
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
fd
));
return
backend
().
add_datagram_sink
(
this
,
fd
);
}
void
abstract_broker
::
add_datagram_source
(
const
intrusive_ptr
<
datagram_source
>&
ptr
)
{
datagram_sources_
.
emplace
(
ptr
->
hdl
(),
ptr
);
// TODO: some launching of things?
}
expected
<
std
::
pair
<
datagram_source_handle
,
uint16_t
>>
abstract_broker
::
add_datagram_source
(
uint16_t
port
,
const
char
*
in
,
bool
reuse_addr
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
port
)
<<
CAF_ARG
(
in
)
<<
CAF_ARG
(
reuse_addr
));
return
backend
().
add_datagram_source
(
this
,
port
,
in
,
reuse_addr
);
}
expected
<
void
>
abstract_broker
::
assign_datagram_source
(
datagram_source_handle
hdl
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
));
return
backend
().
assign_datagram_source
(
this
,
hdl
);
}
expected
<
datagram_source_handle
>
abstract_broker
::
add_datagram_source
(
network
::
native_socket
fd
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
fd
));
return
backend
().
add_datagram_source
(
this
,
fd
);
}
std
::
string
abstract_broker
::
remote_addr
(
connection_handle
hdl
)
{
auto
i
=
scribes_
.
find
(
hdl
);
return
i
!=
scribes_
.
end
()
?
i
->
second
->
addr
()
:
std
::
string
{};
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
abbd084f
This diff is collapsed.
Click to expand it.
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