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
e24ad712
Commit
e24ad712
authored
Sep 17, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add additional static assertions
parent
f0c25cbd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
16 deletions
+33
-16
libcaf_core/caf/attach_continuous_stream_source.hpp
libcaf_core/caf/attach_continuous_stream_source.hpp
+15
-7
libcaf_core/caf/attach_stream_source.hpp
libcaf_core/caf/attach_stream_source.hpp
+17
-8
libcaf_core/test/composable_behavior.cpp
libcaf_core/test/composable_behavior.cpp
+1
-1
No files found.
libcaf_core/caf/attach_continuous_stream_source.hpp
View file @
e24ad712
...
...
@@ -38,14 +38,11 @@ namespace caf {
/// @param done Predicate returning `true` when generator is done.
/// @param fin Cleanup handler.
/// @returns The new `stream_manager`.
template
<
class
Driver
,
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
>
template
<
class
Driver
,
class
...
Ts
>
typename
Driver
::
source_ptr_type
attach_continuous_stream_source
(
scheduled_actor
*
self
,
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{})
{
attach_continuous_stream_source
(
scheduled_actor
*
self
,
Ts
&&
...
xs
)
{
using
detail
::
make_stream_source
;
auto
mgr
=
make_stream_source
<
Driver
>
(
self
,
std
::
move
(
init
),
std
::
move
(
pull
),
std
::
move
(
done
),
std
::
move
(
fin
));
auto
mgr
=
make_stream_source
<
Driver
>
(
self
,
std
::
forward
<
Ts
>
(
xs
)...);
mgr
->
continuous
(
true
);
return
mgr
;
}
...
...
@@ -60,12 +57,23 @@ attach_continuous_stream_source(scheduled_actor* self, Init init, Pull pull,
/// @param fin Cleanup handler.
/// @returns The new `stream_manager`.
template
<
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
,
class
Trait
=
stream_source_trait_t
<
Pull
>,
class
DownstreamManager
=
broadcast_downstream_manager
<
typename
stream_source_trait_t
<
Pull
>
::
output
>>
typename
Trait
::
output
>>
stream_source_ptr
<
DownstreamManager
>
attach_continuous_stream_source
(
scheduled_actor
*
self
,
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
=
{})
{
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
<
bool
(
const
state_type
&
),
typename
detail
::
get_callable_trait
<
Done
>::
fun_sig
>::
value
,
"Expected signature `bool (const State&)` "
"for done predicate function"
);
using
driver
=
detail
::
stream_source_driver_impl
<
DownstreamManager
,
Pull
,
Done
,
Finalize
>
;
return
attach_continuous_stream_source
<
driver
>
(
self
,
std
::
move
(
init
),
...
...
libcaf_core/caf/attach_stream_source.hpp
View file @
e24ad712
...
...
@@ -45,14 +45,13 @@ namespace caf {
/// @param done Predicate returning `true` when generator is done.
/// @param fin Optional cleanup handler.
/// @returns The allocated `stream_manager` and the output slot.
template
<
class
Driver
,
class
...
Ts
,
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
>
template
<
class
Driver
,
class
...
Ts
,
class
...
CtorArgs
>
make_source_result_t
<
typename
Driver
::
downstream_manager_type
,
Ts
...
>
attach_stream_source
(
scheduled_actor
*
self
,
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{}
)
{
attach_stream_source
(
scheduled_actor
*
self
,
std
::
tuple
<
Ts
...
>
xs
,
CtorArgs
&&
...
ctor_args
)
{
using
namespace
detail
;
auto
mgr
=
make_stream_source
<
Driver
>
(
self
,
std
::
move
(
init
),
std
::
move
(
pull
),
std
::
move
(
done
),
std
::
move
(
fin
)
);
auto
mgr
=
make_stream_source
<
Driver
>
(
self
,
std
::
forward
<
CtorArgs
>
(
ctor_args
)...
);
auto
slot
=
mgr
->
add_outbound_path
(
std
::
move
(
xs
));
return
{
slot
,
std
::
move
(
mgr
)};
}
...
...
@@ -67,13 +66,23 @@ attach_stream_source(scheduled_actor* self, std::tuple<Ts...> xs, Init init,
/// @param fin Cleanup handler.
/// @returns The allocated `stream_manager` and the output slot.
template
<
class
...
Ts
,
class
Init
,
class
Pull
,
class
Done
,
class
Finalize
=
unit_t
,
class
Finalize
=
unit_t
,
class
Trait
=
stream_source_trait_t
<
Pull
>,
class
DownstreamManager
=
broadcast_downstream_manager
<
typename
stream_source_trait_t
<
Pull
>
::
output
>>
typename
Trait
::
output
>>
make_source_result_t
<
DownstreamManager
,
Ts
...
>
attach_stream_source
(
scheduled_actor
*
self
,
std
::
tuple
<
Ts
...
>
xs
,
Init
init
,
Pull
pull
,
Done
done
,
Finalize
fin
=
{},
policy
::
arg
<
DownstreamManager
>
=
{})
{
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
<
bool
(
const
state_type
&
),
typename
detail
::
get_callable_trait
<
Done
>::
fun_sig
>::
value
,
"Expected signature `bool (const State&)` "
"for done predicate function"
);
using
driver
=
detail
::
stream_source_driver_impl
<
DownstreamManager
,
Pull
,
Done
,
Finalize
>
;
return
attach_stream_source
<
driver
>
(
self
,
std
::
move
(
xs
),
std
::
move
(
init
),
...
...
libcaf_core/test/composable_behavior.cpp
View file @
e24ad712
...
...
@@ -99,7 +99,7 @@ public:
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
out
.
push
(
counter
++
);
},
[](
const
in
t
&
counter
)
{
return
counter
<
100
;
});
[](
const
size_
t
&
counter
)
{
return
counter
<
100
;
});
}
};
...
...
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