mirror of https://github.com/fafhrd91/actix-net
less likely to fail system arbiter stop test
This commit is contained in:
parent
21ba890c0a
commit
b5f2c4ead8
|
@ -28,6 +28,7 @@ enum PatternElement {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
enum PatternType {
|
||||
Static(String),
|
||||
Prefix(String),
|
||||
|
|
|
@ -113,10 +113,11 @@ impl Arbiter {
|
|||
where
|
||||
F: Fn() -> tokio::runtime::Runtime + Send + 'static,
|
||||
{
|
||||
let id = COUNT.fetch_add(1, Ordering::Relaxed);
|
||||
let system_id = System::current().id();
|
||||
let name = format!("actix-rt|system:{}|arbiter:{}", system_id, id);
|
||||
let sys = System::current();
|
||||
let system_id = sys.id();
|
||||
let arb_id = COUNT.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
let name = format!("actix-rt|system:{}|arbiter:{}", system_id, arb_id);
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
|
||||
let (ready_tx, ready_rx) = std::sync::mpsc::channel::<()>();
|
||||
|
@ -136,7 +137,7 @@ impl Arbiter {
|
|||
// register arbiter
|
||||
let _ = System::current()
|
||||
.tx()
|
||||
.send(SystemCommand::RegisterArbiter(id, hnd));
|
||||
.send(SystemCommand::RegisterArbiter(arb_id, hnd));
|
||||
|
||||
ready_tx.send(()).unwrap();
|
||||
|
||||
|
@ -146,7 +147,7 @@ impl Arbiter {
|
|||
// deregister arbiter
|
||||
let _ = System::current()
|
||||
.tx()
|
||||
.send(SystemCommand::DeregisterArbiter(id));
|
||||
.send(SystemCommand::DeregisterArbiter(arb_id));
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|err| {
|
||||
|
|
|
@ -198,6 +198,9 @@ fn system_stop_stops_arbiters() {
|
|||
System::current().stop();
|
||||
sys.run().unwrap();
|
||||
|
||||
// account for slightly slow thread de-spawns (only observed on windows)
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
|
||||
// arbiter should be dead and return false
|
||||
assert!(!Arbiter::current().spawn_fn(|| {}));
|
||||
assert!(!arb.spawn_fn(|| {}));
|
||||
|
|
Loading…
Reference in New Issue