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
4a62632f
Commit
4a62632f
authored
Jul 22, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate review feedback
parent
dbc51213
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
12 deletions
+15
-12
libcaf_net/caf/net/socket_manager.hpp
libcaf_net/caf/net/socket_manager.hpp
+4
-4
libcaf_net/caf/net/stream_socket.hpp
libcaf_net/caf/net/stream_socket.hpp
+2
-2
libcaf_net/src/multiplexer.cpp
libcaf_net/src/multiplexer.cpp
+6
-5
libcaf_net/src/pollset_updater.cpp
libcaf_net/src/pollset_updater.cpp
+3
-1
No files found.
libcaf_net/caf/net/socket_manager.hpp
View file @
4a62632f
...
@@ -52,18 +52,18 @@ public:
...
@@ -52,18 +52,18 @@ public:
return
handle_
;
return
handle_
;
}
}
/// Returns
for which operations the socket is registered (read or write
).
/// Returns
registered operations (read, write, or both
).
operation
mask
()
const
noexcept
;
operation
mask
()
const
noexcept
;
/// Adds given flag(s) to the event mask and updates the parent on success.
/// Adds given flag(s) to the event mask and updates the parent on success.
/// @returns `false` if `mask()
` already contained `flag
`, `true` otherwise.
/// @returns `false` if `mask()
| flag == mask()
`, `true` otherwise.
/// @pre `has_parent()`
/// @pre `has_parent()`
/// @pre `flag != operation::none`
/// @pre `flag != operation::none`
bool
mask_add
(
operation
flag
)
noexcept
;
bool
mask_add
(
operation
flag
)
noexcept
;
/// Deletes given flag(s) from the event mask and updates the parent on
/// Deletes given flag(s) from the event mask and updates the parent on
/// success.
/// success.
/// @returns `false` if `mask()
` already missed `flag
`, `true` otherwise.
/// @returns `false` if `mask()
& ~flag == mask()
`, `true` otherwise.
/// @pre `has_parent()`
/// @pre `has_parent()`
/// @pre `flag != operation::none`
/// @pre `flag != operation::none`
bool
mask_del
(
operation
flag
)
noexcept
;
bool
mask_del
(
operation
flag
)
noexcept
;
...
@@ -73,7 +73,7 @@ public:
...
@@ -73,7 +73,7 @@ public:
/// Called whenever the socket received new data.
/// Called whenever the socket received new data.
virtual
bool
handle_read_event
()
=
0
;
virtual
bool
handle_read_event
()
=
0
;
/// Called whenever the socket is allowed to send
additional
data.
/// Called whenever the socket is allowed to send data.
virtual
bool
handle_write_event
()
=
0
;
virtual
bool
handle_write_event
()
=
0
;
/// Called when the remote side becomes unreachable due to an error.
/// Called when the remote side becomes unreachable due to an error.
...
...
libcaf_net/caf/net/stream_socket.hpp
View file @
4a62632f
...
@@ -59,7 +59,7 @@ error nodelay(stream_socket x, bool new_value);
...
@@ -59,7 +59,7 @@ error nodelay(stream_socket x, bool new_value);
/// @param buf_size Specifies the maximum size of the buffer in bytes.
/// @param buf_size Specifies the maximum size of the buffer in bytes.
/// @returns The number of received bytes on success, an error code otherwise.
/// @returns The number of received bytes on success, an error code otherwise.
/// @relates pipe_socket
/// @relates pipe_socket
/// @post either the result is a `sec` or a positive (non-zero) integer
.
/// @post either the result is a `sec` or a positive (non-zero) integer
variant
<
size_t
,
sec
>
read
(
stream_socket
x
,
void
*
buf
,
size_t
buf_size
);
variant
<
size_t
,
sec
>
read
(
stream_socket
x
,
void
*
buf
,
size_t
buf_size
);
/// Transmits data from `x` to its peer.
/// Transmits data from `x` to its peer.
...
@@ -68,7 +68,7 @@ variant<size_t, sec> read(stream_socket x, void* buf, size_t buf_size);
...
@@ -68,7 +68,7 @@ variant<size_t, sec> read(stream_socket x, void* buf, size_t buf_size);
/// @param buf_size Specifies the size of the buffer in bytes.
/// @param buf_size Specifies the size of the buffer in bytes.
/// @returns The number of written bytes on success, otherwise an error code.
/// @returns The number of written bytes on success, otherwise an error code.
/// @relates pipe_socket
/// @relates pipe_socket
/// @post either the result is a `sec` or a positive (non-zero) integer
.
/// @post either the result is a `sec` or a positive (non-zero) integer
variant
<
size_t
,
sec
>
write
(
stream_socket
x
,
const
void
*
buf
,
size_t
buf_size
);
variant
<
size_t
,
sec
>
write
(
stream_socket
x
,
const
void
*
buf
,
size_t
buf_size
);
}
// namespace net
}
// namespace net
...
...
libcaf_net/src/multiplexer.cpp
View file @
4a62632f
...
@@ -18,6 +18,8 @@
...
@@ -18,6 +18,8 @@
#include "caf/net/multiplexer.hpp"
#include "caf/net/multiplexer.hpp"
#include <algorithm>
#include "caf/config.hpp"
#include "caf/config.hpp"
#include "caf/error.hpp"
#include "caf/error.hpp"
#include "caf/expected.hpp"
#include "caf/expected.hpp"
...
@@ -97,11 +99,10 @@ size_t multiplexer::num_socket_managers() const noexcept {
...
@@ -97,11 +99,10 @@ size_t multiplexer::num_socket_managers() const noexcept {
}
}
ptrdiff_t
multiplexer
::
index_of
(
const
socket_manager_ptr
&
mgr
)
{
ptrdiff_t
multiplexer
::
index_of
(
const
socket_manager_ptr
&
mgr
)
{
auto
max_index
=
static_cast
<
ptrdiff_t
>
(
managers_
.
size
());
auto
first
=
managers_
.
begin
();
for
(
ptrdiff_t
index
=
0
;
index
<
max_index
;
++
index
)
auto
last
=
managers_
.
end
();
if
(
managers_
[
index
]
==
mgr
)
auto
i
=
std
::
find
(
first
,
last
,
mgr
);
return
index
;
return
i
==
last
?
-
1
:
std
::
distance
(
first
,
i
);
return
-
1
;
}
}
void
multiplexer
::
update
(
const
socket_manager_ptr
&
mgr
)
{
void
multiplexer
::
update
(
const
socket_manager_ptr
&
mgr
)
{
...
...
libcaf_net/src/pollset_updater.cpp
View file @
4a62632f
...
@@ -29,6 +29,7 @@ pollset_updater::pollset_updater(pipe_socket read_handle,
...
@@ -29,6 +29,7 @@ pollset_updater::pollset_updater(pipe_socket read_handle,
multiplexer_ptr
parent
)
multiplexer_ptr
parent
)
:
super
(
read_handle
,
std
::
move
(
parent
))
{
:
super
(
read_handle
,
std
::
move
(
parent
))
{
mask_
=
operation
::
read
;
mask_
=
operation
::
read
;
nonblocking
(
read_handle
,
true
);
}
}
pollset_updater
::~
pollset_updater
()
{
pollset_updater
::~
pollset_updater
()
{
...
@@ -44,9 +45,10 @@ bool pollset_updater::handle_read_event() {
...
@@ -44,9 +45,10 @@ bool pollset_updater::handle_read_event() {
socket_manager_ptr
mgr
{
reinterpret_cast
<
socket_manager
*>
(
value
),
false
};
socket_manager_ptr
mgr
{
reinterpret_cast
<
socket_manager
*>
(
value
),
false
};
if
(
auto
ptr
=
parent_
.
lock
())
if
(
auto
ptr
=
parent_
.
lock
())
ptr
->
update
(
mgr
);
ptr
->
update
(
mgr
);
}
}
else
{
return
get
<
sec
>
(
res
)
==
sec
::
unavailable_or_would_block
;
return
get
<
sec
>
(
res
)
==
sec
::
unavailable_or_would_block
;
}
}
}
}
}
bool
pollset_updater
::
handle_write_event
()
{
bool
pollset_updater
::
handle_write_event
()
{
...
...
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