mirror of
https://github.com/fafhrd91/actix-net
synced 2025-02-20 10:00:31 +01:00
sync wait for service factories to be ready
This commit is contained in:
parent
7d98247cb0
commit
15279eaf3d
@ -296,7 +296,8 @@ impl ServerWorker {
|
|||||||
// get actix system context if it is set
|
// get actix system context if it is set
|
||||||
let sys = System::try_current();
|
let sys = System::try_current();
|
||||||
|
|
||||||
// TODO: wait for server startup with sync channel
|
// service factories initialization channel
|
||||||
|
let (factory_tx, factory_rx) = std::sync::mpsc::sync_channel(1);
|
||||||
|
|
||||||
std::thread::Builder::new()
|
std::thread::Builder::new()
|
||||||
.name(format!("actix-server worker {}", idx))
|
.name(format!("actix-server worker {}", idx))
|
||||||
@ -350,6 +351,8 @@ impl ServerWorker {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
factory_tx.send(()).unwrap();
|
||||||
|
|
||||||
// a third spawn to make sure ServerWorker runs as non boxed future.
|
// a third spawn to make sure ServerWorker runs as non boxed future.
|
||||||
spawn(ServerWorker {
|
spawn(ServerWorker {
|
||||||
rx,
|
rx,
|
||||||
@ -369,6 +372,9 @@ impl ServerWorker {
|
|||||||
})
|
})
|
||||||
.expect("worker thread error/panic");
|
.expect("worker thread error/panic");
|
||||||
|
|
||||||
|
// wait for service factories initialization
|
||||||
|
factory_rx.recv().unwrap();
|
||||||
|
|
||||||
Ok(handle_pair(idx, tx1, tx2, counter))
|
Ok(handle_pair(idx, tx1, tx2, counter))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user