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
5498fe5e
Commit
5498fe5e
authored
Aug 14, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing do_on_next operator
parent
19a141fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
libcaf_core/caf/flow/observable.hpp
libcaf_core/caf/flow/observable.hpp
+12
-0
libcaf_core/caf/flow/step.hpp
libcaf_core/caf/flow/step.hpp
+41
-0
No files found.
libcaf_core/caf/flow/observable.hpp
View file @
5498fe5e
...
...
@@ -183,6 +183,12 @@ public:
return
transform
(
do_on_error_step
<
T
,
F
>
{
std
::
move
(
f
)});
}
/// Registers a callback that runs on `on_next`.
template
<
class
F
>
auto
do_on_next
(
F
f
)
{
return
transform
(
do_on_next_step
<
F
>
{
std
::
move
(
f
)});
}
/// Registers a callback that runs on `on_complete` or `on_error`.
template
<
class
F
>
auto
do_finally
(
F
f
)
{
...
...
@@ -1224,11 +1230,17 @@ public:
.
transform
(
do_on_error_step
<
output_type
,
F
>
{
std
::
move
(
f
)});
}
template
<
class
F
>
auto
do_on_next
(
F
f
)
&&
{
return
std
::
move
(
*
this
).
transform
(
do_on_next_step
<
F
>
{
std
::
move
(
f
)});
}
template
<
class
F
>
auto
do_finally
(
F
f
)
&&
{
return
std
::
move
(
*
this
)
//
.
transform
(
do_finally_step
<
output_type
,
F
>
{
std
::
move
(
f
)});
}
auto
on_error_complete
()
{
return
std
::
move
(
*
this
)
//
.
transform
(
on_error_complete_step
<
output_type
>
{});
...
...
libcaf_core/caf/flow/step.hpp
View file @
5498fe5e
...
...
@@ -154,6 +154,47 @@ struct flat_map_optional_step {
}
};
template
<
class
Fn
>
class
do_on_next_step
{
public:
using
trait
=
detail
::
get_callable_trait_t
<
Fn
>
;
static_assert
(
trait
::
num_args
==
1
,
"do_on_next functions must take exactly one argument"
);
using
input_type
=
std
::
decay_t
<
detail
::
tl_head_t
<
typename
trait
::
arg_types
>>
;
using
output_type
=
input_type
;
explicit
do_on_next_step
(
Fn
fn
)
:
fn_
(
std
::
move
(
fn
))
{
// nop
}
do_on_next_step
(
do_on_next_step
&&
)
=
default
;
do_on_next_step
(
const
do_on_next_step
&
)
=
default
;
do_on_next_step
&
operator
=
(
do_on_next_step
&&
)
=
default
;
do_on_next_step
&
operator
=
(
const
do_on_next_step
&
)
=
default
;
template
<
class
Next
,
class
...
Steps
>
bool
on_next
(
const
input_type
&
item
,
Next
&
next
,
Steps
&
...
steps
)
{
fn_
(
item
);
return
next
.
on_next
(
item
,
steps
...);
}
template
<
class
Next
,
class
...
Steps
>
void
on_complete
(
Next
&
next
,
Steps
&
...
steps
)
{
next
.
on_complete
(
steps
...);
}
template
<
class
Next
,
class
...
Steps
>
void
on_error
(
const
error
&
what
,
Next
&
next
,
Steps
&
...
steps
)
{
next
.
on_error
(
what
,
steps
...);
}
private:
Fn
fn_
;
};
template
<
class
T
,
class
Fn
>
struct
do_on_complete_step
{
using
input_type
=
T
;
...
...
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