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
600bc956
Commit
600bc956
authored
Sep 21, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly shutdown sources, only clear pending data
parent
e14558b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
libcaf_core/caf/detail/stream_source_impl.hpp
libcaf_core/caf/detail/stream_source_impl.hpp
+5
-0
libcaf_core/test/pipeline_streaming.cpp
libcaf_core/test/pipeline_streaming.cpp
+39
-0
No files found.
libcaf_core/caf/detail/stream_source_impl.hpp
View file @
600bc956
...
@@ -52,6 +52,11 @@ public:
...
@@ -52,6 +52,11 @@ public:
// -- implementation of virtual functions ------------------------------------
// -- implementation of virtual functions ------------------------------------
void
shutdown
()
override
{
super
::
shutdown
();
at_end_
=
true
;
}
bool
done
()
const
override
{
bool
done
()
const
override
{
return
this
->
pending_handshakes_
==
0
&&
at_end_
&&
this
->
out_
.
clean
();
return
this
->
pending_handshakes_
==
0
&&
at_end_
&&
this
->
out_
.
clean
();
}
}
...
...
libcaf_core/test/pipeline_streaming.cpp
View file @
600bc956
...
@@ -74,6 +74,28 @@ std::function<void (T&, const error&)> fin(scheduled_actor* self) {
...
@@ -74,6 +74,28 @@ std::function<void (T&, const error&)> fin(scheduled_actor* self) {
};
};
}
}
TESTEE
(
infinite_source
)
{
return
{
[
=
](
string
&
fname
)
->
output_stream
<
int
>
{
CAF_CHECK_EQUAL
(
fname
,
"numbers.txt"
);
CAF_CHECK_EQUAL
(
self
->
mailbox
().
empty
(),
true
);
return
self
->
make_source
(
[](
int
&
x
)
{
x
=
0
;
},
[](
int
&
x
,
downstream
<
int
>&
out
,
size_t
num
)
{
for
(
size_t
i
=
0
;
i
<
num
;
++
i
)
out
.
push
(
x
++
);
},
[](
const
int
&
)
{
return
false
;
},
fin
<
int
>
(
self
)
);
}
};
}
VARARGS_TESTEE
(
file_reader
,
size_t
buf_size
)
{
VARARGS_TESTEE
(
file_reader
,
size_t
buf_size
)
{
return
{
return
{
[
=
](
string
&
fname
)
->
output_stream
<
int
>
{
[
=
](
string
&
fname
)
->
output_stream
<
int
>
{
...
@@ -441,4 +463,21 @@ CAF_TEST(depth_3_pipeline_graceful_shutdown) {
...
@@ -441,4 +463,21 @@ CAF_TEST(depth_3_pipeline_graceful_shutdown) {
CAF_CHECK_EQUAL
(
deref
<
sum_up_actor
>
(
snk
).
state
.
x
,
625
);
CAF_CHECK_EQUAL
(
deref
<
sum_up_actor
>
(
snk
).
state
.
x
,
625
);
}
}
CAF_TEST
(
depth_3_pipeline_infinite_source
)
{
auto
src
=
sys
.
spawn
(
infinite_source
);
auto
stg
=
sys
.
spawn
(
filter
);
auto
snk
=
sys
.
spawn
(
sum_up
);
CAF_MESSAGE
(
CAF_ARG
(
self
)
<<
CAF_ARG
(
src
)
<<
CAF_ARG
(
stg
)
<<
CAF_ARG
(
snk
));
CAF_MESSAGE
(
"initiate stream handshake"
);
self
->
send
(
snk
*
stg
*
src
,
"numbers.txt"
);
expect
((
string
),
from
(
self
).
to
(
src
).
with
(
"numbers.txt"
));
expect
((
open_stream_msg
),
from
(
self
).
to
(
stg
));
expect
((
open_stream_msg
),
from
(
self
).
to
(
snk
));
expect
((
upstream_msg
::
ack_open
),
from
(
snk
).
to
(
stg
));
expect
((
upstream_msg
::
ack_open
),
from
(
stg
).
to
(
src
));
CAF_MESSAGE
(
"send exit to the source and expect the stream to terminate"
);
anon_send_exit
(
src
,
exit_reason
::
user_shutdown
);
run
();
}
CAF_TEST_FIXTURE_SCOPE_END
()
CAF_TEST_FIXTURE_SCOPE_END
()
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