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
a634eda4
Commit
a634eda4
authored
Sep 16, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update documentation and comments of composed_type
parent
97024e8c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
19 deletions
+15
-19
libcaf_core/caf/composed_type.hpp
libcaf_core/caf/composed_type.hpp
+15
-19
No files found.
libcaf_core/caf/composed_type.hpp
View file @
a634eda4
...
@@ -26,40 +26,36 @@ namespace caf {
...
@@ -26,40 +26,36 @@ namespace caf {
/// Computes the type for f*g (actor composition).
/// Computes the type for f*g (actor composition).
///
///
/// ~~~
/// This metaprogramming function implements the following pseudo-code (with
/// let output_type x = case x of Stream y -> y ; Single y -> y
/// `f` and `g` modelled as pairs where the first element is the input type and
/// the second type is the output type).
///
///
/// let propagate_stream from to = case from of
/// ~~~
/// Stream _ -> Stream (output_type to)
/// Single _ -> to
/// let composed_type f g =
/// let composed_type f g =
/// [(fst x,
propagate_stream (snd x) (snd y)
) | x <- g, y <- f,
/// [(fst x,
snd y
) | x <- g, y <- f,
///
output_type (snd x)
== fst y]
///
snd x
== fst y]
/// ~~~
/// ~~~
///
///
/// This class implements the list comprehension above in a
/// This class implements the list comprehension above in a single shot with
/// single shot with worst case n*m template instantiations using an
/// worst case n*m template instantiations using an inner and outer loop, where
/// inner and outer loop, where n is the size
/// n is the size of `Xs` and m the size of `Ys`. `Zs` is a helper that models
/// of Xs and m the size of Ys. Zs is a helper that models the
/// the "inner loop variable" for generating the cross product of `Xs` and
/// "inner loop variable" for generating the cross product of Xs and Ys.
/// `Ys`. `Rs` collects the results.
/// The helper function propagate_stream is integrated into the loop with
/// four cases for the matching case. Rs collects the results.
template
<
class
Xs
,
class
Ys
,
class
Zs
,
class
Rs
>
template
<
class
Xs
,
class
Ys
,
class
Zs
,
class
Rs
>
struct
composed_type
;
struct
composed_type
;
//
end of outer loop over Xs
//
End of outer loop over Xs.
template
<
class
Ys
,
class
Zs
,
class
...
Rs
>
template
<
class
Ys
,
class
Zs
,
class
...
Rs
>
struct
composed_type
<
detail
::
type_list
<>
,
Ys
,
Zs
,
detail
::
type_list
<
Rs
...
>>
{
struct
composed_type
<
detail
::
type_list
<>
,
Ys
,
Zs
,
detail
::
type_list
<
Rs
...
>>
{
using
type
=
typed_actor
<
Rs
...
>
;
using
type
=
typed_actor
<
Rs
...
>
;
};
};
//
end of inner loop Ys (Zs)
//
End of inner loop Ys (Zs).
template
<
class
X
,
class
...
Xs
,
class
Ys
,
class
Rs
>
template
<
class
X
,
class
...
Xs
,
class
Ys
,
class
Rs
>
struct
composed_type
<
detail
::
type_list
<
X
,
Xs
...
>
,
Ys
,
detail
::
type_list
<>
,
Rs
>
struct
composed_type
<
detail
::
type_list
<
X
,
Xs
...
>
,
Ys
,
detail
::
type_list
<>
,
Rs
>
:
composed_type
<
detail
::
type_list
<
Xs
...
>
,
Ys
,
Ys
,
Rs
>
{};
:
composed_type
<
detail
::
type_list
<
Xs
...
>
,
Ys
,
Ys
,
Rs
>
{};
//
case #1
//
Output type matches the input type of the next actor.
template
<
class
...
In
,
class
...
Out
,
class
...
Xs
,
class
Ys
,
class
...
MapsTo
,
template
<
class
...
In
,
class
...
Out
,
class
...
Xs
,
class
Ys
,
class
...
MapsTo
,
class
...
Zs
,
class
...
Rs
>
class
...
Zs
,
class
...
Rs
>
struct
composed_type
<
struct
composed_type
<
...
@@ -75,7 +71,7 @@ struct composed_type<
...
@@ -75,7 +71,7 @@ struct composed_type<
Rs
...,
typed_mpi
<
detail
::
type_list
<
In
...
>
,
output_tuple
<
MapsTo
...
>>>>
{
Rs
...,
typed_mpi
<
detail
::
type_list
<
In
...
>
,
output_tuple
<
MapsTo
...
>>>>
{
};
};
//
default case (recurse over Zs)
//
No match, recurse over Zs.
template
<
class
In
,
class
Out
,
class
...
Xs
,
class
Ys
,
class
Unrelated
,
template
<
class
In
,
class
Out
,
class
...
Xs
,
class
Ys
,
class
Unrelated
,
class
MapsTo
,
class
...
Zs
,
class
Rs
>
class
MapsTo
,
class
...
Zs
,
class
Rs
>
struct
composed_type
<
detail
::
type_list
<
typed_mpi
<
In
,
Out
>
,
Xs
...
>
,
Ys
,
struct
composed_type
<
detail
::
type_list
<
typed_mpi
<
In
,
Out
>
,
Xs
...
>
,
Ys
,
...
...
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