···8686 /// Used to efficiently drain the queue while the lock is externally held
8787 pub fn drain(self: *Self) ?T {
8888 if (self.isEmptyLH()) return null;
8989- return self.popLH();
8989+ // Preserve queue push wakeups when draining under external lock.
9090+ // If the queue was full before this pop, a producer may be blocked
9191+ // waiting on not_full.
9292+ const was_full = self.isFullLH();
9393+ const item = self.popLH();
9494+ if (was_full) {
9595+ self.not_full.signal();
9696+ }
9797+ return item;
9098 }
919992100 fn isEmptyLH(self: Self) bool {