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
1588071c
Commit
1588071c
authored
Jun 04, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow subscribing to flows with std::ignore
parent
d2e4180a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
libcaf_core/caf/flow/observable.hpp
libcaf_core/caf/flow/observable.hpp
+5
-0
libcaf_core/caf/flow/observable_decl.hpp
libcaf_core/caf/flow/observable_decl.hpp
+7
-0
No files found.
libcaf_core/caf/flow/observable.hpp
View file @
1588071c
...
@@ -470,6 +470,11 @@ disposable observable<T>::subscribe(async::producer_resource<T> resource) {
...
@@ -470,6 +470,11 @@ disposable observable<T>::subscribe(async::producer_resource<T> resource) {
}
}
}
}
template
<
class
T
>
disposable
observable
<
T
>::
subscribe
(
ignore_t
)
{
return
subscribe
(
observer
<
T
>::
ignore
());
}
template
<
class
T
>
template
<
class
T
>
template
<
class
OnNext
>
template
<
class
OnNext
>
disposable
observable
<
T
>::
for_each
(
OnNext
on_next
)
{
disposable
observable
<
T
>::
for_each
(
OnNext
on_next
)
{
...
...
libcaf_core/caf/flow/observable_decl.hpp
View file @
1588071c
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include "caf/intrusive_ptr.hpp"
#include "caf/intrusive_ptr.hpp"
#include <cstddef>
#include <cstddef>
#include <tuple>
#include <utility>
#include <utility>
#include <vector>
#include <vector>
...
@@ -32,6 +33,9 @@ public:
...
@@ -32,6 +33,9 @@ public:
/// The pointer-to-implementation type.
/// The pointer-to-implementation type.
using
pimpl_type
=
intrusive_ptr
<
op
::
base
<
T
>>
;
using
pimpl_type
=
intrusive_ptr
<
op
::
base
<
T
>>
;
/// Type for drop-all subscribers.
using
ignore_t
=
decltype
(
std
::
ignore
);
// -- constructors, destructors, and assignment operators --------------------
// -- constructors, destructors, and assignment operators --------------------
explicit
observable
(
pimpl_type
pimpl
)
noexcept
:
pimpl_
(
std
::
move
(
pimpl
))
{
explicit
observable
(
pimpl_type
pimpl
)
noexcept
:
pimpl_
(
std
::
move
(
pimpl
))
{
...
@@ -57,6 +61,9 @@ public:
...
@@ -57,6 +61,9 @@ public:
/// Creates a new observer that pushes all observed items to the resource.
/// Creates a new observer that pushes all observed items to the resource.
disposable
subscribe
(
async
::
producer_resource
<
T
>
resource
);
disposable
subscribe
(
async
::
producer_resource
<
T
>
resource
);
/// Subscribes a new observer to the items emitted by this observable.
disposable
subscribe
(
ignore_t
);
/// Calls `on_next` for each item emitted by this observable.
/// Calls `on_next` for each item emitted by this observable.
template
<
class
OnNext
>
template
<
class
OnNext
>
disposable
for_each
(
OnNext
on_next
);
disposable
for_each
(
OnNext
on_next
);
...
...
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