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
0c76c395
Commit
0c76c395
authored
Aug 04, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify receive loop
parent
ea9def46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
22 deletions
+9
-22
libcaf_io/caf/io/network/stream.hpp
libcaf_io/caf/io/network/stream.hpp
+9
-22
No files found.
libcaf_io/caf/io/network/stream.hpp
View file @
0c76c395
...
...
@@ -101,35 +101,22 @@ protected:
CAF_LOG_TRACE
(
CAF_ARG
(
op
));
switch
(
op
)
{
case
io
:
:
network
::
operation
::
read
:
{
// Stores how many bytes the last read_some() procued.
// Loop until an error occurs or we have nothing more to read
// or until we have handled `mcr` reads.
size_t
rb
=
0
;
// Threshold configured by the actor's read policy.
auto
threshold
=
[
&
]
{
CAF_ASSERT
(
read_threshold_
>=
collected_
);
return
read_threshold_
-
collected_
;
};
// Returns how much bytes the next read_some() wants to read.
auto
read_size
=
[
&
]
{
return
rd_buf_
.
size
()
-
collected_
;
};
// Returns `true` if we could read something, `false` otherwise.
auto
read_some
=
[
&
]
{
return
policy
.
read_some
(
rb
,
fd
(),
rd_buf_
.
data
()
+
collected_
,
read_size
());
};
// Loop until reaching the mcr threshold or an error occurs.
size_t
reads
=
0
;
for
(;
reads
<
max_consecutive_reads_
;
++
reads
)
if
(
!
handle_read_result
(
read_some
(),
rb
))
while
(
reads
<
max_consecutive_reads_
||
policy
.
must_read_more
(
fd
(),
threshold
()))
{
auto
res
=
policy
.
read_some
(
rb
,
fd
(),
rd_buf_
.
data
()
+
collected_
,
rd_buf_
.
size
()
-
collected_
);
if
(
!
handle_read_result
(
res
,
rb
))
return
;
// Some policies (such as SSL) buffer data internally. In this case, we
// have to read more despite having reached max_consecutive_reads_.
// Otherwise, brokers can block despite having data to read and lose
// data at the end of a transmission.
if
(
reads
==
max_consecutive_reads_
)
while
(
policy
.
must_read_more
(
fd
(),
threshold
()))
if
(
!
handle_read_result
(
read_some
(),
rb
))
return
;
++
reads
;
}
break
;
}
case
io
:
:
network
::
operation
::
write
:
{
...
...
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