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
0ea433f3
Commit
0ea433f3
authored
Sep 03, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add attach_continuous_stream_stage
The new free function replaces scheduled_actor::make_continuous_stage.
parent
6a47f60d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
5 deletions
+91
-5
libcaf_core/caf/all.hpp
libcaf_core/caf/all.hpp
+1
-0
libcaf_core/caf/attach_continuous_stream_stage.hpp
libcaf_core/caf/attach_continuous_stream_stage.hpp
+81
-0
libcaf_core/caf/attach_stream_stage.hpp
libcaf_core/caf/attach_stream_stage.hpp
+1
-0
libcaf_core/caf/scheduled_actor.hpp
libcaf_core/caf/scheduled_actor.hpp
+2
-3
libcaf_core/test/continuous_streaming.cpp
libcaf_core/test/continuous_streaming.cpp
+3
-1
libcaf_core/test/selective_streaming.cpp
libcaf_core/test/selective_streaming.cpp
+3
-1
No files found.
libcaf_core/caf/all.hpp
View file @
0ea433f3
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include "caf/after.hpp"
#include "caf/after.hpp"
#include "caf/atom.hpp"
#include "caf/atom.hpp"
#include "caf/attach_continuous_stream_source.hpp"
#include "caf/attach_continuous_stream_source.hpp"
#include "caf/attach_continuous_stream_stage.hpp"
#include "caf/attach_stream_sink.hpp"
#include "caf/attach_stream_sink.hpp"
#include "caf/attach_stream_source.hpp"
#include "caf/attach_stream_source.hpp"
#include "caf/attach_stream_stage.hpp"
#include "caf/attach_stream_stage.hpp"
...
...
libcaf_core/caf/attach_continuous_stream_stage.hpp
0 → 100644
View file @
0ea433f3
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#pragma once
#include "caf/default_downstream_manager.hpp"
#include "caf/detail/stream_stage_driver_impl.hpp"
#include "caf/detail/stream_stage_impl.hpp"
#include "caf/downstream_manager.hpp"
#include "caf/fwd.hpp"
#include "caf/make_stage_result.hpp"
#include "caf/policy/arg.hpp"
#include "caf/stream.hpp"
#include "caf/stream_source.hpp"
#include "caf/unit.hpp"
namespace
caf
{
/// Returns a stream manager (implementing a continuous stage) without in- or
/// outbound path. The returned manager is not connected to any slot and thus
/// not stored by the actor automatically.
/// @param self Points to the hosting actor.
/// @param xs User-defined arguments for the downstream handshake.
/// @returns The new `stream_manager`.
template
<
class
Driver
,
class
...
Ts
>
typename
Driver
::
stage_ptr_type
attach_continuous_stream_stage
(
scheduled_actor
*
self
,
Ts
&&
...
xs
)
{
auto
ptr
=
detail
::
make_stream_stage
<
Driver
>
(
self
,
std
::
forward
<
Ts
>
(
xs
)...);
ptr
->
continuous
(
true
);
return
ptr
;
}
/// @param self Points to the hosting actor.
/// @param init Function object for initializing the state of the stage.
/// @param fun Processing function.
/// @param fin Optional cleanup handler.
/// @param token Policy token for selecting a downstream manager
/// implementation.
template
<
class
Init
,
class
Fun
,
class
Finalize
=
unit_t
,
class
DownstreamManager
=
default_downstream_manager_t
<
Fun
>,
class
Trait
=
stream_stage_trait_t
<
Fun
>>
stream_stage_ptr
<
typename
Trait
::
input
,
DownstreamManager
>
attach_continuous_stream_stage
(
scheduled_actor
*
self
,
Init
init
,
Fun
fun
,
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
token
=
{})
{
CAF_IGNORE_UNUSED
(
token
);
using
input_type
=
typename
Trait
::
input
;
using
output_type
=
typename
Trait
::
output
;
using
state_type
=
typename
Trait
::
state
;
static_assert
(
std
::
is_same
<
void
(
state_type
&
),
typename
detail
::
get_callable_trait
<
Init
>::
fun_sig
>::
value
,
"Expected signature `void (State&)` for init function"
);
static_assert
(
std
::
is_same
<
void
(
state_type
&
,
downstream
<
output_type
>&
,
input_type
),
typename
detail
::
get_callable_trait
<
Fun
>::
fun_sig
>::
value
,
"Expected signature `void (State&, downstream<Out>&, In)` "
"for consume function"
);
using
detail
::
stream_stage_driver_impl
;
using
driver
=
stream_stage_driver_impl
<
typename
Trait
::
input
,
DownstreamManager
,
Fun
,
Finalize
>
;
return
attach_continuous_stream_stage
<
driver
>
(
self
,
std
::
move
(
init
),
std
::
move
(
fun
),
std
::
move
(
fin
));
}
}
// namespace caf
libcaf_core/caf/attach_stream_stage.hpp
View file @
0ea433f3
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "caf/policy/arg.hpp"
#include "caf/policy/arg.hpp"
#include "caf/stream.hpp"
#include "caf/stream.hpp"
#include "caf/stream_source.hpp"
#include "caf/stream_source.hpp"
#include "caf/unit.hpp"
namespace
caf
{
namespace
caf
{
...
...
libcaf_core/caf/scheduled_actor.hpp
View file @
0ea433f3
...
@@ -594,9 +594,7 @@ public:
...
@@ -594,9 +594,7 @@ public:
std
::
move
(
fin
),
token
);
std
::
move
(
fin
),
token
);
}
}
/// Returns a stream manager (implementing a continuous stage) without in- or
/// @deprecated Please use `attach_continuous_stream_stage` instead.
/// outbound path. The returned manager is not connected to any slot and thus
/// not stored by the actor automatically.
template
<
class
Driver
,
class
...
Ts
>
template
<
class
Driver
,
class
...
Ts
>
typename
Driver
::
stage_ptr_type
make_continuous_stage
(
Ts
&&
...
xs
)
{
typename
Driver
::
stage_ptr_type
make_continuous_stage
(
Ts
&&
...
xs
)
{
auto
ptr
=
detail
::
make_stream_stage
<
Driver
>
(
this
,
std
::
forward
<
Ts
>
(
xs
)...);
auto
ptr
=
detail
::
make_stream_stage
<
Driver
>
(
this
,
std
::
forward
<
Ts
>
(
xs
)...);
...
@@ -604,6 +602,7 @@ public:
...
@@ -604,6 +602,7 @@ public:
return
ptr
;
return
ptr
;
}
}
/// @deprecated Please use `attach_continuous_stream_stage` instead.
template
<
class
Init
,
class
Fun
,
class
Cleanup
,
template
<
class
Init
,
class
Fun
,
class
Cleanup
,
class
DownstreamManager
=
default_downstream_manager_t
<
Fun
>,
class
DownstreamManager
=
default_downstream_manager_t
<
Fun
>,
class
Trait
=
stream_stage_trait_t
<
Fun
>>
class
Trait
=
stream_stage_trait_t
<
Fun
>>
...
...
libcaf_core/test/continuous_streaming.cpp
View file @
0ea433f3
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "caf/actor_system.hpp"
#include "caf/actor_system.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/attach_continuous_stream_stage.hpp"
#include "caf/attach_stream_sink.hpp"
#include "caf/attach_stream_sink.hpp"
#include "caf/event_based_actor.hpp"
#include "caf/event_based_actor.hpp"
#include "caf/stateful_actor.hpp"
#include "caf/stateful_actor.hpp"
...
@@ -112,7 +113,8 @@ TESTEE_STATE(stream_multiplexer) {
...
@@ -112,7 +113,8 @@ TESTEE_STATE(stream_multiplexer) {
};
};
TESTEE
(
stream_multiplexer
)
{
TESTEE
(
stream_multiplexer
)
{
self
->
state
.
stage
=
self
->
make_continuous_stage
(
self
->
state
.
stage
=
attach_continuous_stream_stage
(
self
,
// initialize state
// initialize state
[](
unit_t
&
)
{
[](
unit_t
&
)
{
// nop
// nop
...
...
libcaf_core/test/selective_streaming.cpp
View file @
0ea433f3
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "caf/actor_system.hpp"
#include "caf/actor_system.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/atom.hpp"
#include "caf/atom.hpp"
#include "caf/attach_continuous_stream_stage.hpp"
#include "caf/attach_stream_sink.hpp"
#include "caf/attach_stream_sink.hpp"
#include "caf/attach_stream_source.hpp"
#include "caf/attach_stream_source.hpp"
#include "caf/broadcast_downstream_manager.hpp"
#include "caf/broadcast_downstream_manager.hpp"
...
@@ -107,7 +108,8 @@ TESTEE_STATE(log_dispatcher) {
...
@@ -107,7 +108,8 @@ TESTEE_STATE(log_dispatcher) {
};
};
TESTEE
(
log_dispatcher
)
{
TESTEE
(
log_dispatcher
)
{
self
->
state
.
stage
=
self
->
make_continuous_stage
(
self
->
state
.
stage
=
attach_continuous_stream_stage
(
self
,
// initialize state
// initialize state
[](
unit_t
&
)
{
[](
unit_t
&
)
{
// nop
// nop
...
...
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