Add note for field order of ServerWorker

This commit is contained in:
fakeshadow 2021-04-15 21:07:59 +08:00
parent b18dd4b05f
commit 6c18af80f0
1 changed files with 3 additions and 3 deletions

View File

@ -125,6 +125,8 @@ impl WorkerAvailability {
///
/// Worker accepts Socket objects via unbounded channel and starts stream processing.
pub(crate) struct ServerWorker {
// UnboundedReceiver<Conn> should always the first field.
// It must be dropped as soon as ServerWorker dropping.
rx: UnboundedReceiver<Conn>,
rx2: UnboundedReceiver<Stop>,
services: Box<[WorkerService]>,
@ -370,9 +372,7 @@ impl Default for WorkerState {
impl Drop for ServerWorker {
fn drop(&mut self) {
/// Close channel on drop.
self.rx.close();
/// Stop Arbiter Self runs on on drop.
// Stop Arbiter Self runs on on drop.
Arbiter::current().stop();
}
}