Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
ddd26fa9
Unverified
Commit
ddd26fa9
authored
Jan 08, 2021
by
Fedor Sakharov
Browse files
Fuse receive stream in Context
parent
05b91fb4
Pipeline
#119283
canceled with stages
in 14 minutes and 39 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
node/overseer/src/lib.rs
View file @
ddd26fa9
...
...
@@ -70,7 +70,7 @@ use futures::channel::{mpsc, oneshot};
use
futures
::{
poll
,
select
,
future
::
BoxFuture
,
stream
::{
self
,
FuturesUnordered
},
stream
::{
self
,
Fuse
,
FusedStream
,
FuturesUnordered
},
Future
,
FutureExt
,
SinkExt
,
StreamExt
,
};
use
futures_timer
::
Delay
;
...
...
@@ -323,7 +323,7 @@ impl<T> From<T> for MaybeTimed<T> {
/// [`SubsystemJob`]: trait.SubsystemJob.html
#[derive(Debug)]
pub
struct
OverseerSubsystemContext
<
M
>
{
rx
:
mpsc
::
Receiver
<
FromOverseer
<
M
>>
,
rx
:
Fuse
<
mpsc
::
Receiver
<
FromOverseer
<
M
>>
>
,
tx
:
mpsc
::
Sender
<
MaybeTimed
<
ToOverseer
>>
,
metrics
:
Metrics
,
rng
:
Rand32
,
...
...
@@ -354,6 +354,7 @@ impl<M> OverseerSubsystemContext<M> {
}
let
threshold
=
(
capture_rate
*
u32
::
MAX
as
f64
)
as
u32
;
let
rx
=
rx
.fuse
();
OverseerSubsystemContext
{
rx
,
tx
,
metrics
,
rng
,
threshold
}
}
...
...
@@ -415,11 +416,18 @@ impl<M: Send + 'static> SubsystemContext for OverseerSubsystemContext<M> {
}
async
fn
recv
(
&
mut
self
)
->
SubsystemResult
<
FromOverseer
<
M
>>
{
self
.rx
.next
()
.await
.ok_or
(
SubsystemError
::
Context
(
"No more messages in rx queue to process"
if
!
self
.rx
.is_terminated
()
{
self
.rx
.next
()
.await
.ok_or
(
SubsystemError
::
Context
(
"No more messages in rx queue to process"
.to_owned
()
))
}
else
{
Err
(
SubsystemError
::
Context
(
"Node is shutting down"
.to_owned
()
))
}
}
async
fn
spawn
(
&
mut
self
,
name
:
&
'static
str
,
s
:
Pin
<
Box
<
dyn
Future
<
Output
=
()
>
+
Send
>>
)
...
...
Fedor Sakharov
@montekki
mentioned in commit
de6ef375
·
Jan 08, 2021
mentioned in commit
de6ef375
mentioned in commit de6ef37547de9f85ad9e93476650d88d67bdcc41
Toggle commit list
Fedor Sakharov
@montekki
mentioned in commit
6cfab385
·
Jan 08, 2021
mentioned in commit
6cfab385
mentioned in commit 6cfab385e6022be4e64201e252a98c6782d49224
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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