mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
Overseer: subsystems communicate directly (#2227)
* overseer: pass messages directly between subsystems * test that message is held on to * Update node/overseer/src/lib.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * give every subsystem an unbounded sender too * remove metered_channel::name 1. we don't provide good names 2. these names are never used anywhere * unused mut * remove unnecessary &mut * subsystem unbounded_send * remove unused MaybeTimer We have channel size metrics that serve the same purpose better now and the implementation of message timing was pretty ugly. * remove comment * split up senders and receivers * update metrics * fix tests * fix test subsystem context * fix flaky test * fix docs * doc * use select_biased to favor signals * Update node/subsystem/src/lib.rs Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
committed by
GitHub
parent
c6f07d8f31
commit
5952e790fa
@@ -30,8 +30,6 @@ pub use self::unbounded::*;
|
||||
/// A peek into the inner state of a meter.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Meter {
|
||||
/// Name of the receiver and sender pair.
|
||||
name: &'static str,
|
||||
// Number of sends on this channel.
|
||||
sent: Arc<AtomicUsize>,
|
||||
// Number of receives on this channel.
|
||||
@@ -60,11 +58,6 @@ impl Meter {
|
||||
}
|
||||
}
|
||||
|
||||
/// Obtain the name of the channel `Sender` and `Receiver` pair.
|
||||
pub fn name(&self) -> &'static str {
|
||||
self.name
|
||||
}
|
||||
|
||||
fn note_sent(&self) {
|
||||
self.sent.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
@@ -92,7 +85,7 @@ mod tests {
|
||||
#[test]
|
||||
fn try_send_try_next() {
|
||||
block_on(async move {
|
||||
let (mut tx, mut rx) = channel::<Msg>(5, "goofy");
|
||||
let (mut tx, mut rx) = channel::<Msg>(5);
|
||||
let msg = Msg::default();
|
||||
assert_eq!(rx.meter().read(), Readout { sent: 0, received: 0 });
|
||||
tx.try_send(msg).unwrap();
|
||||
@@ -116,7 +109,7 @@ mod tests {
|
||||
fn with_tasks() {
|
||||
let (ready, go) = futures::channel::oneshot::channel();
|
||||
|
||||
let (mut tx, mut rx) = channel::<Msg>(5, "goofy");
|
||||
let (mut tx, mut rx) = channel::<Msg>(5);
|
||||
block_on(async move {
|
||||
futures::join!(
|
||||
async move {
|
||||
@@ -149,7 +142,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn stream_and_sink() {
|
||||
let (mut tx, mut rx) = channel::<Msg>(5, "goofy");
|
||||
let (mut tx, mut rx) = channel::<Msg>(5);
|
||||
|
||||
block_on(async move {
|
||||
futures::join!(
|
||||
@@ -175,8 +168,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn failed_send_does_not_inc_sent() {
|
||||
let (mut bounded, _) = channel::<Msg>(5, "pluto");
|
||||
let (mut unbounded, _) = unbounded::<Msg>("pluto");
|
||||
let (mut bounded, _) = channel::<Msg>(5);
|
||||
let (mut unbounded, _) = unbounded::<Msg>();
|
||||
|
||||
block_on(async move {
|
||||
assert!(bounded.send(Msg::default()).await.is_err());
|
||||
|
||||
Reference in New Issue
Block a user