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
c2758a4b
Commit
c2758a4b
authored
Apr 16, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix typos and inconsistencies
parent
04e02412
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
80 additions
and
128 deletions
+80
-128
libcaf_core/caf/async/blocking_consumer.hpp
libcaf_core/caf/async/blocking_consumer.hpp
+1
-1
libcaf_core/caf/async/blocking_producer.hpp
libcaf_core/caf/async/blocking_producer.hpp
+4
-4
libcaf_core/caf/disposable.hpp
libcaf_core/caf/disposable.hpp
+0
-1
libcaf_core/caf/flow/observable.hpp
libcaf_core/caf/flow/observable.hpp
+18
-39
libcaf_core/caf/flow/observable_decl.hpp
libcaf_core/caf/flow/observable_decl.hpp
+4
-9
libcaf_core/caf/flow/observer.hpp
libcaf_core/caf/flow/observer.hpp
+10
-10
libcaf_core/caf/flow/op/cell.hpp
libcaf_core/caf/flow/op/cell.hpp
+1
-1
libcaf_core/caf/flow/op/concat.hpp
libcaf_core/caf/flow/op/concat.hpp
+4
-4
libcaf_core/caf/flow/op/empty.hpp
libcaf_core/caf/flow/op/empty.hpp
+2
-2
libcaf_core/caf/flow/op/from_generator.hpp
libcaf_core/caf/flow/op/from_generator.hpp
+1
-1
libcaf_core/caf/flow/op/from_resource.hpp
libcaf_core/caf/flow/op/from_resource.hpp
+1
-1
libcaf_core/caf/flow/op/from_steps.hpp
libcaf_core/caf/flow/op/from_steps.hpp
+5
-5
libcaf_core/caf/flow/op/mcast.hpp
libcaf_core/caf/flow/op/mcast.hpp
+1
-1
libcaf_core/caf/flow/op/merge.hpp
libcaf_core/caf/flow/op/merge.hpp
+5
-5
libcaf_core/caf/flow/op/never.hpp
libcaf_core/caf/flow/op/never.hpp
+1
-1
libcaf_core/caf/flow/op/prefix_and_tail.hpp
libcaf_core/caf/flow/op/prefix_and_tail.hpp
+4
-4
libcaf_core/caf/flow/op/zip_with.hpp
libcaf_core/caf/flow/op/zip_with.hpp
+7
-7
libcaf_core/caf/flow/subscription.hpp
libcaf_core/caf/flow/subscription.hpp
+5
-10
libcaf_core/src/flow/op/interval.cpp
libcaf_core/src/flow/op/interval.cpp
+1
-1
libcaf_core/src/flow/subscription.cpp
libcaf_core/src/flow/subscription.cpp
+1
-5
libcaf_core/test/flow/generation.cpp
libcaf_core/test/flow/generation.cpp
+2
-2
libcaf_core/test/flow/never.cpp
libcaf_core/test/flow/never.cpp
+2
-14
No files found.
libcaf_core/caf/async/blocking_consumer.hpp
View file @
c2758a4b
...
@@ -70,7 +70,7 @@ public:
...
@@ -70,7 +70,7 @@ public:
// nop
// nop
}
}
void
cancel
()
{
void
dispose
()
{
if
(
buf_
)
{
if
(
buf_
)
{
buf_
->
cancel
();
buf_
->
cancel
();
buf_
=
nullptr
;
buf_
=
nullptr
;
...
...
libcaf_core/caf/async/blocking_producer.hpp
View file @
c2758a4b
...
@@ -66,7 +66,7 @@ public:
...
@@ -66,7 +66,7 @@ public:
}
}
}
}
bool
cancel
l
ed
()
const
{
bool
canceled
()
const
{
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
return
demand_
==
-
1
;
return
demand_
==
-
1
;
}
}
...
@@ -160,9 +160,9 @@ public:
...
@@ -160,9 +160,9 @@ public:
}
}
}
}
/// Checks whether the consumer cancel
l
ed its subscription.
/// Checks whether the consumer canceled its subscription.
bool
cancel
l
ed
()
const
{
bool
canceled
()
const
{
return
impl_
->
cancel
l
ed
();
return
impl_
->
canceled
();
}
}
private:
private:
...
...
libcaf_core/caf/disposable.hpp
View file @
c2758a4b
...
@@ -57,7 +57,6 @@ public:
...
@@ -57,7 +57,6 @@ public:
return
*
this
;
return
*
this
;
}
}
// -- factories --------------------------------------------------------------
// -- factories --------------------------------------------------------------
/// Combines multiple disposables into a single disposable. The new disposable
/// Combines multiple disposables into a single disposable. The new disposable
...
...
libcaf_core/caf/flow/observable.hpp
View file @
c2758a4b
...
@@ -195,11 +195,6 @@ public:
...
@@ -195,11 +195,6 @@ public:
return
std
::
move
(
*
this
).
transform
(
map_step
<
F
>
{
std
::
move
(
f
)});
return
std
::
move
(
*
this
).
transform
(
map_step
<
F
>
{
std
::
move
(
f
)});
}
}
template
<
class
F
>
auto
flat_map_optional
(
F
f
)
&&
{
return
std
::
move
(
*
this
).
transform
(
flat_map_optional_step
<
F
>
{
std
::
move
(
f
)});
}
template
<
class
F
>
template
<
class
F
>
auto
do_on_next
(
F
f
)
&&
{
auto
do_on_next
(
F
f
)
&&
{
return
std
::
move
(
*
this
)
//
return
std
::
move
(
*
this
)
//
...
@@ -336,17 +331,17 @@ disposable observable<T>::for_each(OnNext on_next, OnError on_error,
...
@@ -336,17 +331,17 @@ disposable observable<T>::for_each(OnNext on_next, OnError on_error,
// -- observable::merge --------------------------------------------------------
// -- observable::merge --------------------------------------------------------
template
<
class
T
>
template
<
class
T
>
template
<
class
...
Inputs
>
template
<
class
Out
,
class
...
Inputs
>
auto
observable
<
T
>::
merge
(
Inputs
&&
...
xs
)
{
auto
observable
<
T
>::
merge
(
Inputs
&&
...
xs
)
{
if
constexpr
(
is_observable_v
<
output_type
>
)
{
if
constexpr
(
is_observable_v
<
Out
>
)
{
using
value_t
=
output_type_t
<
output_type
>
;
using
value_t
=
output_type_t
<
Out
>
;
using
impl_t
=
op
::
merge
<
value_t
>
;
using
impl_t
=
op
::
merge
<
value_t
>
;
return
make_observable
<
impl_t
>
(
ctx
(),
*
this
,
std
::
forward
<
Inputs
>
(
xs
)...);
return
make_observable
<
impl_t
>
(
ctx
(),
*
this
,
std
::
forward
<
Inputs
>
(
xs
)...);
}
else
{
}
else
{
static_assert
(
static_assert
(
sizeof
...(
Inputs
)
>
0
,
sizeof
...(
Inputs
)
>
0
,
"merge without arguments expects this observable to emit observables"
);
"merge without arguments expects this observable to emit observables"
);
using
impl_t
=
op
::
merge
<
output_type
>
;
using
impl_t
=
op
::
merge
<
Out
>
;
return
make_observable
<
impl_t
>
(
ctx
(),
*
this
,
std
::
forward
<
Inputs
>
(
xs
)...);
return
make_observable
<
impl_t
>
(
ctx
(),
*
this
,
std
::
forward
<
Inputs
>
(
xs
)...);
}
}
}
}
...
@@ -354,18 +349,16 @@ auto observable<T>::merge(Inputs&&... xs) {
...
@@ -354,18 +349,16 @@ auto observable<T>::merge(Inputs&&... xs) {
// -- observable::flat_map -----------------------------------------------------
// -- observable::flat_map -----------------------------------------------------
template
<
class
T
>
template
<
class
T
>
template
<
class
F
>
template
<
class
Out
,
class
F
>
auto
observable
<
T
>::
flat_map
(
F
f
)
{
auto
observable
<
T
>::
flat_map
(
F
f
)
{
using
res_t
=
decltype
(
f
(
std
::
declval
<
const
output_type
&>
()));
using
res_t
=
decltype
(
f
(
std
::
declval
<
const
Out
&>
()));
if
constexpr
(
is_observable_v
<
res_t
>
)
{
if
constexpr
(
is_observable_v
<
res_t
>
)
{
return
map
([
fn
=
std
::
move
(
f
)](
const
output_type
&
x
)
mutable
{
return
map
([
fn
=
std
::
move
(
f
)](
const
Out
&
x
)
mutable
{
return
fn
(
x
).
as_observable
();
return
fn
(
x
).
as_observable
();
})
})
.
merge
();
.
merge
();
}
else
if
constexpr
(
detail
::
is_optional_v
<
res_t
>
)
{
}
else
if
constexpr
(
detail
::
is_optional_v
<
res_t
>
)
{
return
map
([
fn
=
std
::
move
(
f
)](
const
output_type
&
x
)
mutable
{
return
map
([
fn
=
std
::
move
(
f
)](
const
Out
&
x
)
mutable
{
return
fn
(
x
);
})
return
fn
(
x
);
})
.
filter
([](
const
res_t
&
x
)
{
return
x
.
has_value
();
})
.
filter
([](
const
res_t
&
x
)
{
return
x
.
has_value
();
})
.
map
([](
const
res_t
&
x
)
{
return
*
x
;
});
.
map
([](
const
res_t
&
x
)
{
return
*
x
;
});
}
else
{
}
else
{
...
@@ -374,39 +367,27 @@ auto observable<T>::flat_map(F f) {
...
@@ -374,39 +367,27 @@ auto observable<T>::flat_map(F f) {
// all available immediately, there is no good reason to mess up the emitted
// all available immediately, there is no good reason to mess up the emitted
// order of values.
// order of values.
static_assert
(
detail
::
is_iterable_v
<
res_t
>
);
static_assert
(
detail
::
is_iterable_v
<
res_t
>
);
return
map
([
cptr
=
ctx
(),
fn
=
std
::
move
(
f
)](
const
output_type
&
x
)
mutable
{
return
map
([
cptr
=
ctx
(),
fn
=
std
::
move
(
f
)](
const
Out
&
x
)
mutable
{
return
cptr
->
make_observable
().
from_container
(
fn
(
x
));
return
cptr
->
make_observable
().
from_container
(
fn
(
x
));
})
})
.
concat
();
.
concat
();
}
}
}
}
// -- observable::flat_map_optional --------------------------------------------
template
<
class
T
>
template
<
class
F
>
transformation
<
flat_map_optional_step
<
F
>>
observable
<
T
>::
flat_map_optional
(
F
f
)
{
using
step_type
=
flat_map_optional_step
<
F
>
;
static_assert
(
std
::
is_same_v
<
typename
step_type
::
input_type
,
T
>
,
"flat_map_optional function does not match the input type"
);
return
{
*
this
,
std
::
forward_as_tuple
(
step_type
{
std
::
move
(
f
)})};
}
// -- observable::concat -------------------------------------------------------
// -- observable::concat -------------------------------------------------------
template
<
class
T
>
template
<
class
T
>
template
<
class
...
Inputs
>
template
<
class
Out
,
class
...
Inputs
>
auto
observable
<
T
>::
concat
(
Inputs
&&
...
xs
)
{
auto
observable
<
T
>::
concat
(
Inputs
&&
...
xs
)
{
if
constexpr
(
is_observable_v
<
output_type
>
)
{
if
constexpr
(
is_observable_v
<
Out
>
)
{
using
value_t
=
output_type_t
<
output_type
>
;
using
value_t
=
output_type_t
<
Out
>
;
using
impl_t
=
op
::
concat
<
value_t
>
;
using
impl_t
=
op
::
concat
<
value_t
>
;
return
make_observable
<
impl_t
>
(
ctx
(),
*
this
,
std
::
forward
<
Inputs
>
(
xs
)...);
return
make_observable
<
impl_t
>
(
ctx
(),
*
this
,
std
::
forward
<
Inputs
>
(
xs
)...);
}
else
{
}
else
{
static_assert
(
static_assert
(
sizeof
...(
Inputs
)
>
0
,
sizeof
...(
Inputs
)
>
0
,
"merge without arguments expects this observable to emit observables"
);
"merge without arguments expects this observable to emit observables"
);
using
impl_t
=
op
::
concat
<
output_type
>
;
using
impl_t
=
op
::
concat
<
Out
>
;
return
make_observable
<
impl_t
>
(
ctx
(),
*
this
,
std
::
forward
<
Inputs
>
(
xs
)...);
return
make_observable
<
impl_t
>
(
ctx
(),
*
this
,
std
::
forward
<
Inputs
>
(
xs
)...);
}
}
}
}
...
@@ -414,23 +395,21 @@ auto observable<T>::concat(Inputs&&... xs) {
...
@@ -414,23 +395,21 @@ auto observable<T>::concat(Inputs&&... xs) {
// -- observable::concat_map ---------------------------------------------------
// -- observable::concat_map ---------------------------------------------------
template
<
class
T
>
template
<
class
T
>
template
<
class
F
>
template
<
class
Out
,
class
F
>
auto
observable
<
T
>::
concat_map
(
F
f
)
{
auto
observable
<
T
>::
concat_map
(
F
f
)
{
using
res_t
=
decltype
(
f
(
std
::
declval
<
const
output_type
&>
()));
using
res_t
=
decltype
(
f
(
std
::
declval
<
const
Out
&>
()));
if
constexpr
(
is_observable_v
<
res_t
>
)
{
if
constexpr
(
is_observable_v
<
res_t
>
)
{
return
map
([
fn
=
std
::
move
(
f
)](
const
output_type
&
x
)
mutable
{
return
map
([
fn
=
std
::
move
(
f
)](
const
Out
&
x
)
mutable
{
return
fn
(
x
).
as_observable
();
return
fn
(
x
).
as_observable
();
})
})
.
concat
();
.
concat
();
}
else
if
constexpr
(
detail
::
is_optional_v
<
res_t
>
)
{
}
else
if
constexpr
(
detail
::
is_optional_v
<
res_t
>
)
{
return
map
([
fn
=
std
::
move
(
f
)](
const
output_type
&
x
)
mutable
{
return
map
([
fn
=
std
::
move
(
f
)](
const
Out
&
x
)
mutable
{
return
fn
(
x
);
})
return
fn
(
x
);
})
.
filter
([](
const
res_t
&
x
)
{
return
x
.
has_value
();
})
.
filter
([](
const
res_t
&
x
)
{
return
x
.
has_value
();
})
.
map
([](
const
res_t
&
x
)
{
return
*
x
;
});
.
map
([](
const
res_t
&
x
)
{
return
*
x
;
});
}
else
{
}
else
{
static_assert
(
detail
::
is_iterable_v
<
res_t
>
);
static_assert
(
detail
::
is_iterable_v
<
res_t
>
);
return
map
([
cptr
=
ctx
(),
fn
=
std
::
move
(
f
)](
const
output_type
&
x
)
mutable
{
return
map
([
cptr
=
ctx
(),
fn
=
std
::
move
(
f
)](
const
Out
&
x
)
mutable
{
return
cptr
->
make_observable
().
from_container
(
fn
(
x
));
return
cptr
->
make_observable
().
from_container
(
fn
(
x
));
})
})
.
concat
();
.
concat
();
...
...
libcaf_core/caf/flow/observable_decl.hpp
View file @
c2758a4b
...
@@ -137,28 +137,23 @@ public:
...
@@ -137,28 +137,23 @@ public:
/// Combines the output of multiple @ref observable objects into one by
/// Combines the output of multiple @ref observable objects into one by
/// merging their outputs. May also be called without arguments if the `T` is
/// merging their outputs. May also be called without arguments if the `T` is
/// an @ref observable.
/// an @ref observable.
template
<
class
...
Inputs
>
template
<
class
Out
=
output_type
,
class
...
Inputs
>
auto
merge
(
Inputs
&&
...
xs
);
auto
merge
(
Inputs
&&
...
xs
);
/// Combines the output of multiple @ref observable objects into one by
/// Combines the output of multiple @ref observable objects into one by
/// concatenating their outputs. May also be called without arguments if the
/// concatenating their outputs. May also be called without arguments if the
/// `T` is an @ref observable.
/// `T` is an @ref observable.
template
<
class
...
Inputs
>
template
<
class
Out
=
output_type
,
class
...
Inputs
>
auto
concat
(
Inputs
&&
...);
auto
concat
(
Inputs
&&
...);
/// Returns a transformation that emits items by merging the outputs of all
/// Returns a transformation that emits items by merging the outputs of all
/// observables returned by `f`.
/// observables returned by `f`.
template
<
class
F
>
template
<
class
Out
=
output_type
,
class
F
>
auto
flat_map
(
F
f
);
auto
flat_map
(
F
f
);
/// Returns a transformation that emits items from optional values returned by
/// `f`.
template
<
class
F
>
transformation
<
flat_map_optional_step
<
F
>>
flat_map_optional
(
F
f
);
/// Returns a transformation that emits items by concatenating the outputs of
/// Returns a transformation that emits items by concatenating the outputs of
/// all observables returned by `f`.
/// all observables returned by `f`.
template
<
class
F
>
template
<
class
Out
=
output_type
,
class
F
>
auto
concat_map
(
F
f
);
auto
concat_map
(
F
f
);
/// Takes @p prefix_size elements from this observable and emits it in a tuple
/// Takes @p prefix_size elements from this observable and emits it in a tuple
...
...
libcaf_core/caf/flow/observer.hpp
View file @
c2758a4b
...
@@ -211,7 +211,7 @@ public:
...
@@ -211,7 +211,7 @@ public:
sub_
=
std
::
move
(
sub
);
sub_
=
std
::
move
(
sub
);
sub_
.
request
(
defaults
::
flow
::
buffer_size
);
sub_
.
request
(
defaults
::
flow
::
buffer_size
);
}
else
{
}
else
{
sub
.
cancel
();
sub
.
dispose
();
}
}
}
}
...
@@ -355,7 +355,7 @@ public:
...
@@ -355,7 +355,7 @@ public:
sub_
=
std
::
move
(
sub
);
sub_
=
std
::
move
(
sub
);
}
else
{
}
else
{
CAF_LOG_DEBUG
(
"already have a subscription or buffer no longer valid"
);
CAF_LOG_DEBUG
(
"already have a subscription or buffer no longer valid"
);
sub
.
cancel
();
sub
.
dispose
();
}
}
}
}
...
@@ -399,7 +399,7 @@ private:
...
@@ -399,7 +399,7 @@ private:
void
on_cancel
()
{
void
on_cancel
()
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
if
(
sub_
)
{
if
(
sub_
)
{
sub_
.
cancel
();
sub_
.
dispose
();
sub_
=
nullptr
;
sub_
=
nullptr
;
}
}
buf_
=
nullptr
;
buf_
=
nullptr
;
...
@@ -457,7 +457,7 @@ public:
...
@@ -457,7 +457,7 @@ public:
if
(
parent_
)
{
if
(
parent_
)
{
parent_
->
fwd_on_subscribe
(
token_
,
std
::
move
(
new_sub
));
parent_
->
fwd_on_subscribe
(
token_
,
std
::
move
(
new_sub
));
}
else
{
}
else
{
new_sub
.
cancel
();
new_sub
.
dispose
();
}
}
}
}
...
@@ -491,7 +491,7 @@ public:
...
@@ -491,7 +491,7 @@ public:
void
on_complete
()
override
{
void
on_complete
()
override
{
if
(
sub
)
{
if
(
sub
)
{
sub
.
cancel
();
sub
.
dispose
();
sub
=
nullptr
;
sub
=
nullptr
;
}
}
state
=
observer_state
::
completed
;
state
=
observer_state
::
completed
;
...
@@ -499,7 +499,7 @@ public:
...
@@ -499,7 +499,7 @@ public:
void
on_error
(
const
error
&
what
)
override
{
void
on_error
(
const
error
&
what
)
override
{
if
(
sub
)
{
if
(
sub
)
{
sub
.
cancel
();
sub
.
dispose
();
sub
=
nullptr
;
sub
=
nullptr
;
}
}
err
=
what
;
err
=
what
;
...
@@ -512,7 +512,7 @@ public:
...
@@ -512,7 +512,7 @@ public:
sub
=
std
::
move
(
new_sub
);
sub
=
std
::
move
(
new_sub
);
state
=
observer_state
::
subscribed
;
state
=
observer_state
::
subscribed
;
}
else
{
}
else
{
new_sub
.
cancel
();
new_sub
.
dispose
();
}
}
}
}
...
@@ -577,7 +577,7 @@ public:
...
@@ -577,7 +577,7 @@ public:
void
on_complete
()
override
{
void
on_complete
()
override
{
if
(
sub
)
{
if
(
sub
)
{
sub
.
cancel
();
sub
.
dispose
();
sub
=
nullptr
;
sub
=
nullptr
;
}
}
state
=
observer_state
::
completed
;
state
=
observer_state
::
completed
;
...
@@ -585,7 +585,7 @@ public:
...
@@ -585,7 +585,7 @@ public:
void
on_error
(
const
error
&
what
)
override
{
void
on_error
(
const
error
&
what
)
override
{
if
(
sub
)
{
if
(
sub
)
{
sub
.
cancel
();
sub
.
dispose
();
sub
=
nullptr
;
sub
=
nullptr
;
}
}
err
=
what
;
err
=
what
;
...
@@ -599,7 +599,7 @@ public:
...
@@ -599,7 +599,7 @@ public:
state
=
observer_state
::
subscribed
;
state
=
observer_state
::
subscribed
;
sub
.
request
(
64
);
sub
.
request
(
64
);
}
else
{
}
else
{
new_sub
.
cancel
();
new_sub
.
dispose
();
}
}
}
}
...
...
libcaf_core/caf/flow/op/cell.hpp
View file @
c2758a4b
...
@@ -97,7 +97,7 @@ public:
...
@@ -97,7 +97,7 @@ public:
return
!
state_
;
return
!
state_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
if
(
state_
)
{
if
(
state_
)
{
state_
->
drop
(
out_
);
state_
->
drop
(
out_
);
state_
=
nullptr
;
state_
=
nullptr
;
...
...
libcaf_core/caf/flow/op/concat.hpp
View file @
c2758a4b
...
@@ -83,7 +83,7 @@ public:
...
@@ -83,7 +83,7 @@ public:
factory_sub_
=
std
::
move
(
sub
);
factory_sub_
=
std
::
move
(
sub
);
factory_sub_
.
request
(
1
);
factory_sub_
.
request
(
1
);
}
else
{
}
else
{
sub
.
cancel
();
sub
.
dispose
();
}
}
}
}
...
@@ -134,7 +134,7 @@ public:
...
@@ -134,7 +134,7 @@ public:
return
!
out_
;
return
!
out_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
if
(
out_
)
{
if
(
out_
)
{
ctx_
->
delay_fn
([
strong_this
=
intrusive_ptr
<
concat_sub
>
{
this
}]
{
ctx_
->
delay_fn
([
strong_this
=
intrusive_ptr
<
concat_sub
>
{
this
}]
{
if
(
strong_this
->
out_
)
{
if
(
strong_this
->
out_
)
{
...
@@ -156,11 +156,11 @@ private:
...
@@ -156,11 +156,11 @@ private:
void
fin
()
{
void
fin
()
{
CAF_ASSERT
(
out_
);
CAF_ASSERT
(
out_
);
if
(
factory_sub_
)
{
if
(
factory_sub_
)
{
factory_sub_
.
cancel
();
factory_sub_
.
dispose
();
factory_sub_
=
nullptr
;
factory_sub_
=
nullptr
;
}
}
if
(
active_sub_
)
{
if
(
active_sub_
)
{
active_sub_
.
cancel
();
active_sub_
.
dispose
();
active_sub_
=
nullptr
;
active_sub_
=
nullptr
;
}
}
factory_key_
=
0
;
factory_key_
=
0
;
...
...
libcaf_core/caf/flow/op/empty.hpp
View file @
c2758a4b
...
@@ -29,13 +29,13 @@ public:
...
@@ -29,13 +29,13 @@ public:
return
!
out_
;
return
!
out_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
if
(
out_
)
if
(
out_
)
ctx_
->
delay_fn
([
out
=
std
::
move
(
out_
)]()
mutable
{
out
.
on_complete
();
});
ctx_
->
delay_fn
([
out
=
std
::
move
(
out_
)]()
mutable
{
out
.
on_complete
();
});
}
}
void
request
(
size_t
)
override
{
void
request
(
size_t
)
override
{
cancel
();
dispose
();
}
}
private:
private:
...
...
libcaf_core/caf/flow/op/from_generator.hpp
View file @
c2758a4b
...
@@ -53,7 +53,7 @@ public:
...
@@ -53,7 +53,7 @@ public:
return
!
out_
;
return
!
out_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
if
(
out_
)
{
if
(
out_
)
{
completed_
=
true
;
completed_
=
true
;
buf_
.
clear
();
buf_
.
clear
();
...
...
libcaf_core/caf/flow/op/from_resource.hpp
View file @
c2758a4b
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
return
disposed_
;
return
disposed_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
if
(
!
disposed_
)
{
if
(
!
disposed_
)
{
disposed_
=
true
;
disposed_
=
true
;
...
...
libcaf_core/caf/flow/op/from_steps.hpp
View file @
c2758a4b
...
@@ -42,13 +42,13 @@ public:
...
@@ -42,13 +42,13 @@ public:
void
on_complete
()
{
void
on_complete
()
{
CAF_ASSERT
(
sub
->
in_
.
valid
());
CAF_ASSERT
(
sub
->
in_
.
valid
());
sub
->
in_
.
cancel
();
sub
->
in_
.
dispose
();
sub
->
in_
=
nullptr
;
sub
->
in_
=
nullptr
;
}
}
void
on_error
(
const
error
&
what
)
{
void
on_error
(
const
error
&
what
)
{
CAF_ASSERT
(
sub
->
subscribed
());
CAF_ASSERT
(
sub
->
subscribed
());
sub
->
in_
.
cancel
();
sub
->
in_
.
dispose
();
sub
->
in_
=
nullptr
;
sub
->
in_
=
nullptr
;
sub
->
err_
=
what
;
sub
->
err_
=
what
;
}
}
...
@@ -154,7 +154,7 @@ public:
...
@@ -154,7 +154,7 @@ public:
in_
=
std
::
move
(
in
);
in_
=
std
::
move
(
in
);
pull
();
pull
();
}
else
{
}
else
{
in
.
cancel
();
in
.
dispose
();
}
}
}
}
...
@@ -164,7 +164,7 @@ public:
...
@@ -164,7 +164,7 @@ public:
return
disposed_
;
return
disposed_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
if
(
!
disposed_
)
{
if
(
!
disposed_
)
{
disposed_
=
true
;
disposed_
=
true
;
...
@@ -173,7 +173,7 @@ public:
...
@@ -173,7 +173,7 @@ public:
ctx_
->
delay_fn
([
out
=
std
::
move
(
out_
)]()
mutable
{
out
.
on_complete
();
});
ctx_
->
delay_fn
([
out
=
std
::
move
(
out_
)]()
mutable
{
out
.
on_complete
();
});
}
}
if
(
in_
)
{
if
(
in_
)
{
in_
.
cancel
();
in_
.
dispose
();
in_
=
nullptr
;
in_
=
nullptr
;
}
}
}
}
...
...
libcaf_core/caf/flow/op/mcast.hpp
View file @
c2758a4b
...
@@ -110,7 +110,7 @@ public:
...
@@ -110,7 +110,7 @@ public:
return
!
state_
;
return
!
state_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
if
(
state_
)
{
if
(
state_
)
{
ctx_
->
delay_fn
([
state
=
std
::
move
(
state_
)]()
{
state
->
do_dispose
();
});
ctx_
->
delay_fn
([
state
=
std
::
move
(
state_
)]()
{
state
->
do_dispose
();
});
}
}
...
...
libcaf_core/caf/flow/op/merge.hpp
View file @
c2758a4b
...
@@ -77,7 +77,7 @@ public:
...
@@ -77,7 +77,7 @@ public:
sub
.
request
(
max_pending_
);
sub
.
request
(
max_pending_
);
ptr
->
sub
=
std
::
move
(
sub
);
ptr
->
sub
=
std
::
move
(
sub
);
}
else
{
}
else
{
sub
.
cancel
();
sub
.
dispose
();
}
}
}
}
...
@@ -102,7 +102,7 @@ public:
...
@@ -102,7 +102,7 @@ public:
while
(
i
!=
inputs_
.
end
())
{
while
(
i
!=
inputs_
.
end
())
{
auto
&
input
=
*
i
->
second
;
auto
&
input
=
*
i
->
second
;
if
(
auto
&
sub
=
input
.
sub
)
{
if
(
auto
&
sub
=
input
.
sub
)
{
sub
.
cancel
();
sub
.
dispose
();
sub
=
nullptr
;
sub
=
nullptr
;
}
}
if
(
input
.
buf
.
empty
())
if
(
input
.
buf
.
empty
())
...
@@ -138,11 +138,11 @@ public:
...
@@ -138,11 +138,11 @@ public:
return
!
out_
;
return
!
out_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
if
(
out_
)
{
if
(
out_
)
{
for
(
auto
&
kvp
:
inputs_
)
for
(
auto
&
kvp
:
inputs_
)
if
(
auto
&
sub
=
kvp
.
second
->
sub
)
if
(
auto
&
sub
=
kvp
.
second
->
sub
)
sub
.
cancel
();
sub
.
dispose
();
inputs_
.
clear
();
inputs_
.
clear
();
run_later
();
run_later
();
}
}
...
@@ -215,7 +215,7 @@ private:
...
@@ -215,7 +215,7 @@ private:
if
(
!
inputs_
.
empty
())
{
if
(
!
inputs_
.
empty
())
{
for
(
auto
&
kvp
:
inputs_
)
for
(
auto
&
kvp
:
inputs_
)
if
(
auto
&
sub
=
kvp
.
second
->
sub
)
if
(
auto
&
sub
=
kvp
.
second
->
sub
)
sub
.
cancel
();
sub
.
dispose
();
inputs_
.
clear
();
inputs_
.
clear
();
}
}
if
(
!
err_
)
{
if
(
!
err_
)
{
...
...
libcaf_core/caf/flow/op/never.hpp
View file @
c2758a4b
...
@@ -28,7 +28,7 @@ public:
...
@@ -28,7 +28,7 @@ public:
return
!
out_
;
return
!
out_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
if
(
out_
)
if
(
out_
)
ctx_
->
delay_fn
([
out
=
std
::
move
(
out_
)]()
mutable
{
out
.
on_complete
();
});
ctx_
->
delay_fn
([
out
=
std
::
move
(
out_
)]()
mutable
{
out
.
on_complete
();
});
}
}
...
...
libcaf_core/caf/flow/op/prefix_and_tail.hpp
View file @
c2758a4b
...
@@ -93,7 +93,7 @@ public:
...
@@ -93,7 +93,7 @@ public:
}
}
void
on_subscribe
(
subscription
in
)
override
{
void
on_subscribe
(
subscription
in
)
override
{
in
.
cancel
();
in
.
dispose
();
}
}
// -- implementation of subscription_impl ------------------------------------
// -- implementation of subscription_impl ------------------------------------
...
@@ -102,9 +102,9 @@ public:
...
@@ -102,9 +102,9 @@ public:
return
!
out_
;
return
!
out_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
if
(
in_
)
{
if
(
in_
)
{
in_
.
cancel
();
in_
.
dispose
();
in_
=
nullptr
;
in_
=
nullptr
;
}
}
if
(
out_
)
{
if
(
out_
)
{
...
@@ -145,7 +145,7 @@ public:
...
@@ -145,7 +145,7 @@ public:
~
pipe
()
{
~
pipe
()
{
if
(
sub_
)
if
(
sub_
)
sub_
->
cancel
();
sub_
->
dispose
();
}
}
disposable
subscribe
(
observer
<
T
>
out
)
override
{
disposable
subscribe
(
observer
<
T
>
out
)
override
{
...
...
libcaf_core/caf/flow/op/zip_with.hpp
View file @
c2758a4b
...
@@ -21,13 +21,13 @@
...
@@ -21,13 +21,13 @@
namespace
caf
::
flow
::
op
{
namespace
caf
::
flow
::
op
{
template
<
class
F
,
class
...
Ts
>
template
<
class
F
,
class
...
Ts
>
struct
zip_wi
c
h_oracle
{
struct
zip_wi
t
h_oracle
{
using
output_type
using
output_type
=
decltype
(
std
::
declval
<
F
&>
()(
std
::
declval
<
const
Ts
&>
()...));
=
decltype
(
std
::
declval
<
F
&>
()(
std
::
declval
<
const
Ts
&>
()...));
};
};
template
<
class
F
,
class
...
Ts
>
template
<
class
F
,
class
...
Ts
>
using
zip_with_output_t
=
typename
zip_wi
c
h_oracle
<
F
,
Ts
...
>::
output_type
;
using
zip_with_output_t
=
typename
zip_wi
t
h_oracle
<
F
,
Ts
...
>::
output_type
;
template
<
size_t
Index
>
template
<
size_t
Index
>
using
zip_index
=
std
::
integral_constant
<
size_t
,
Index
>
;
using
zip_index
=
std
::
integral_constant
<
size_t
,
Index
>
;
...
@@ -73,11 +73,11 @@ public:
...
@@ -73,11 +73,11 @@ public:
return
!
out_
;
return
!
out_
;
}
}
void
cancel
()
override
{
void
dispose
()
override
{
if
(
out_
)
{
if
(
out_
)
{
for_each_input
([](
auto
,
auto
&
input
)
{
for_each_input
([](
auto
,
auto
&
input
)
{
if
(
input
.
sub
)
{
if
(
input
.
sub
)
{
input
.
sub
.
cancel
();
input
.
sub
.
dispose
();
input
.
sub
=
nullptr
;
input
.
sub
=
nullptr
;
}
}
input
.
buf
.
clear
();
input
.
buf
.
clear
();
...
@@ -143,10 +143,10 @@ public:
...
@@ -143,10 +143,10 @@ public:
sub
.
request
(
demand_
);
sub
.
request
(
demand_
);
in
.
sub
=
std
::
move
(
sub
);
in
.
sub
=
std
::
move
(
sub
);
}
else
{
}
else
{
sub
.
cancel
();
sub
.
dispose
();
}
}
}
else
{
}
else
{
sub
.
cancel
();
sub
.
dispose
();
}
}
}
}
...
@@ -203,7 +203,7 @@ private:
...
@@ -203,7 +203,7 @@ private:
void
fin
()
{
void
fin
()
{
for_each_input
([](
auto
,
auto
&
input
)
{
for_each_input
([](
auto
,
auto
&
input
)
{
if
(
input
.
sub
)
{
if
(
input
.
sub
)
{
input
.
sub
.
cancel
();
input
.
sub
.
dispose
();
input
.
sub
=
nullptr
;
input
.
sub
=
nullptr
;
}
}
input
.
buf
.
clear
();
input
.
buf
.
clear
();
...
...
libcaf_core/caf/flow/subscription.hpp
View file @
c2758a4b
...
@@ -27,14 +27,8 @@ public:
...
@@ -27,14 +27,8 @@ public:
public:
public:
~
impl
()
override
;
~
impl
()
override
;
/// Causes the publisher to stop producing items for the subscriber. Any
/// in-flight items may still get dispatched.
virtual
void
cancel
()
=
0
;
/// Signals demand for `n` more items.
/// Signals demand for `n` more items.
virtual
void
request
(
size_t
n
)
=
0
;
virtual
void
request
(
size_t
n
)
=
0
;
void
dispose
()
final
;
};
};
/// Simple base type for all subscription implementations that implements the
/// Simple base type for all subscription implementations that implements the
...
@@ -71,7 +65,7 @@ public:
...
@@ -71,7 +65,7 @@ public:
void
request
(
size_t
n
)
override
;
void
request
(
size_t
n
)
override
;
void
cancel
()
override
;
void
dispose
()
override
;
auto
*
ctx
()
const
noexcept
{
auto
*
ctx
()
const
noexcept
{
return
ctx_
;
return
ctx_
;
...
@@ -125,10 +119,11 @@ public:
...
@@ -125,10 +119,11 @@ public:
// -- demand signaling -------------------------------------------------------
// -- demand signaling -------------------------------------------------------
/// @copydoc impl::cancel
/// Causes the publisher to stop producing items for the subscriber. Any
void
cancel
()
{
/// in-flight items may still get dispatched.
void
dispose
()
{
if
(
pimpl_
)
{
if
(
pimpl_
)
{
pimpl_
->
cancel
();
pimpl_
->
dispose
();
pimpl_
=
nullptr
;
pimpl_
=
nullptr
;
}
}
}
}
...
...
libcaf_core/src/flow/op/interval.cpp
View file @
c2758a4b
...
@@ -69,7 +69,7 @@ public:
...
@@ -69,7 +69,7 @@ public:
// -- implementation of subscription_impl ------------------------------------
// -- implementation of subscription_impl ------------------------------------
void
cancel
()
override
{
void
dispose
()
override
{
if
(
out_
)
{
if
(
out_
)
{
ctx_
->
delay_fn
([
ptr
=
strong_this
()]
{
ptr
->
do_cancel
();
});
ctx_
->
delay_fn
([
ptr
=
strong_this
()]
{
ptr
->
do_cancel
();
});
}
}
...
...
libcaf_core/src/flow/subscription.cpp
View file @
c2758a4b
...
@@ -12,10 +12,6 @@ subscription::impl::~impl() {
...
@@ -12,10 +12,6 @@ subscription::impl::~impl() {
// nop
// nop
}
}
void
subscription
::
impl
::
dispose
()
{
cancel
();
}
void
subscription
::
impl_base
::
ref_disposable
()
const
noexcept
{
void
subscription
::
impl_base
::
ref_disposable
()
const
noexcept
{
this
->
ref
();
this
->
ref
();
}
}
...
@@ -39,7 +35,7 @@ void subscription::fwd_impl::request(size_t n) {
...
@@ -39,7 +35,7 @@ void subscription::fwd_impl::request(size_t n) {
});
});
}
}
void
subscription
::
fwd_impl
::
cancel
()
{
void
subscription
::
fwd_impl
::
dispose
()
{
if
(
src_
)
{
if
(
src_
)
{
ctx
()
->
delay_fn
([
src
=
src_
,
snk
=
snk_
]
{
//
ctx
()
->
delay_fn
([
src
=
src_
,
snk
=
snk_
]
{
//
src
->
on_cancel
(
snk
.
get
());
src
->
on_cancel
(
snk
.
get
());
...
...
libcaf_core/test/flow/generation.cpp
View file @
c2758a4b
...
@@ -42,7 +42,7 @@ SCENARIO("repeater sources repeat one value indefinitely") {
...
@@ -42,7 +42,7 @@ SCENARIO("repeater sources repeat one value indefinitely") {
snk
->
sub
.
request
(
4
);
snk
->
sub
.
request
(
4
);
ctx
->
run
();
ctx
->
run
();
CHECK_EQ
(
snk
->
buf
,
ivec
({
42
,
42
,
42
,
42
,
42
,
42
,
42
}));
CHECK_EQ
(
snk
->
buf
,
ivec
({
42
,
42
,
42
,
42
,
42
,
42
,
42
}));
snk
->
sub
.
cancel
();
snk
->
sub
.
dispose
();
ctx
->
run
();
ctx
->
run
();
CHECK_EQ
(
snk
->
buf
,
ivec
({
42
,
42
,
42
,
42
,
42
,
42
,
42
}));
CHECK_EQ
(
snk
->
buf
,
ivec
({
42
,
42
,
42
,
42
,
42
,
42
,
42
}));
}
}
...
@@ -112,7 +112,7 @@ SCENARIO("callable sources stream values generated from a function object") {
...
@@ -112,7 +112,7 @@ SCENARIO("callable sources stream values generated from a function object") {
snk
->
sub
.
request
(
4
);
snk
->
sub
.
request
(
4
);
ctx
->
run
();
ctx
->
run
();
CHECK_EQ
(
snk
->
buf
,
ivec
({
1
,
2
,
3
,
4
,
5
,
6
,
7
}));
CHECK_EQ
(
snk
->
buf
,
ivec
({
1
,
2
,
3
,
4
,
5
,
6
,
7
}));
snk
->
sub
.
cancel
();
snk
->
sub
.
dispose
();
ctx
->
run
();
ctx
->
run
();
CHECK_EQ
(
snk
->
buf
,
ivec
({
1
,
2
,
3
,
4
,
5
,
6
,
7
}));
CHECK_EQ
(
snk
->
buf
,
ivec
({
1
,
2
,
3
,
4
,
5
,
6
,
7
}));
}
}
...
...
libcaf_core/test/flow/never.cpp
View file @
c2758a4b
...
@@ -23,20 +23,8 @@ struct fixture : test_coordinator_fixture<> {
...
@@ -23,20 +23,8 @@ struct fixture : test_coordinator_fixture<> {
BEGIN_FIXTURE_SCOPE
(
fixture
)
BEGIN_FIXTURE_SCOPE
(
fixture
)
SCENARIO
(
"the never operator never invokes callbacks except when disposed"
)
{
SCENARIO
(
"the never operator never invokes callbacks except when disposed"
)
{
GIVEN
(
"a never<int32>"
)
{
GIVEN
(
"a never operator"
)
{
WHEN
(
"an observer subscribes"
)
{
WHEN
(
"an observer subscribes and disposing the subscription"
)
{
THEN
(
"the observer never receives any events"
)
{
auto
uut
=
ctx
->
make_observable
().
never
<
int32_t
>
();
auto
snk
=
flow
::
make_auto_observer
<
int32_t
>
();
uut
.
subscribe
(
snk
->
as_observer
());
ctx
->
run
();
CHECK
(
snk
->
buf
.
empty
());
CHECK_EQ
(
snk
->
state
,
flow
::
observer_state
::
subscribed
);
}
}
}
GIVEN
(
"a never<int32> that gets disposed"
)
{
WHEN
(
"an observer subscribes"
)
{
THEN
(
"the observer receives on_complete"
)
{
THEN
(
"the observer receives on_complete"
)
{
auto
uut
=
ctx
->
make_observable
().
never
<
int32_t
>
();
auto
uut
=
ctx
->
make_observable
().
never
<
int32_t
>
();
auto
snk1
=
flow
::
make_auto_observer
<
int32_t
>
();
auto
snk1
=
flow
::
make_auto_observer
<
int32_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