fn drop()

in src/sync/rwlock.rs [375:407]


    fn drop(&mut self) {
        self.inner = None;

        let mut state = self.state.borrow_mut();
        trace!(
            holder = ?state.holder,
            waiting_readers = ?state.waiting_readers,
            waiting_writers = ?state.waiting_writers,
            "releasing Write lock on rwlock {:p}",
            self.state
        );

        assert_eq!(state.holder, RwLockHolder::Write(self.me));
        state.holder = RwLockHolder::None;

        // Update the RwLock clock with the owning thread's clock
        ExecutionState::with(|s| {
            let clock = s.increment_clock();
            state.clock.update(clock);
        });

        if ExecutionState::should_stop() {
            return;
        }

        // Unblock every thread waiting on this lock. The scheduler will choose one of them to win
        // the race to this lock, and that thread will re-block all the losers.
        RwLock::<T>::unblock_waiters(&*state, self.me, RwLockType::Write);
        drop(state);

        // Releasing a lock is a yield point
        thread::switch();
    }