unsafe fn swap_active<'a>(&self, alternate: &mut *mut WakeSet) -> &'a mut BitSet {
        // Unlock. At this position, if someone adds an element to the wake set
        // they are also bound to call wake, which will cause us to wake up.
        //
        // There is a race going on between locking and unlocking, and it's
        // beneficial for child tasks to observe the locked state of the wake
        // set so they refetch the other set instead of having to wait until
        // another wakeup.
        (**alternate).unlock_exclusive();

        let next = mem::replace(alternate, ptr::null_mut());
        debug_assert!(!next.is_null());

        *alternate = self.wake_set.swap(next);

        // Make sure no one else is using the alternate wake.
        //
        // Safety: We are the only one swapping alternate, so at
        // this point we know that we have access to the most recent
        // active set. We _must_ call lock_exclusive before we
        // can punt this into a mutable reference though, because at
        // this point inner futures will still have access to references
        // to it (under a lock!). We must wait for these to expire.
        //
        // We also unfortunately can't yield here, because we've swapped the
        // alternate set which could be used when pushing to the set.
        (**alternate).lock_exclusive();

        // Safety: While this is live we must _not_ mess with
        // `alternate` in any way.
        (**alternate).as_mut_set()
    }
/// Perform the actual swap of the active sets.
/// This is safe, because we perform the appropriate locking while swapping
/// the sets.
///
/// # Safety
///
/// We must ensure that we have unique access to the alternate set being
/// swapped.
Perform the actual swap of the active sets.
This is safe, because we perform the appropriate locking while swapping
the sets.
Perform the actual swap of the active sets . This is safe because we perform the appropriate locking while swapping the sets .
unsafe fn swap_active<'a>(&self, alternate: &mut *mut WakeSet) -> &'a mut BitSet {
        // Unlock. At this position, if someone adds an element to the wake set
        // they are also bound to call wake, which will cause us to wake up.
        //
        // There is a race going on between locking and unlocking, and it's
        // beneficial for child tasks to observe the locked state of the wake
        // set so they refetch the other set instead of having to wait until
        // another wakeup.
        (**alternate).unlock_exclusive();
        let next = mem::replace(alternate, ptr::null_mut());
        debug_assert!(!next.is_null());
        *alternate = self.wake_set.swap(next);
        // Make sure no one else is using the alternate wake.
        //
        // Safety: We are the only one swapping alternate, so at
        // this point we know that we have access to the most recent
        // active set. We _must_ call lock_exclusive before we
        // can punt this into a mutable reference though, because at
        // this point inner futures will still have access to references
        // to it (under a lock!). We must wait for these to expire.
        //
        // We also unfortunately can't yield here, because we've swapped the
        // alternate set which could be used when pushing to the set.
        (**alternate).lock_exclusive();
        // Safety: While this is live we must _not_ mess with
        // `alternate` in any way.
        (**alternate).as_mut_set()
    }
unsafe fn swap_active < ' a > ( & self , alternate : & mut * mut WakeSet ) -> & ' a mut BitSet { // Unlock. At this position, if someone adds an element to the wake set // they are also bound to call wake, which will cause us to wake up. // // There is a race going on between locking and unlocking, and it's // beneficial for child tasks to observe the locked state of the wake // set so they refetch the other set instead of having to wait until // another wakeup. ( * * alternate ) . unlock_exclusive ( ) ; let next = mem :: replace ( alternate , ptr :: null_mut ( ) ) ; debug_assert ! ( next is_null ( ) ) ; * alternate = self . wake_set . swap ( next ) ; // Make sure no one else is using the alternate wake. // // Safety: We are the only one swapping alternate, so at // this point we know that we have access to the most recent // active set. We _must_ call lock_exclusive before we // can punt this into a mutable reference though, because at // this point inner futures will still have access to references // to it (under a lock!). We must wait for these to expire. // // We also unfortunately can't yield here, because we've swapped the // alternate set which could be used when pushing to the set. ( * * alternate ) . lock_exclusive ( ) ; // Safety: While this is live we must _not_ mess with // `alternate` in any way. ( * * alternate ) . as_mut_set ( ) }
Perform the actual swap of the active sets.
Perform the actual swap of the active sets .
&self
alternate
&mut *mut WakeSet
&self
alternate
&mut *mut WakeSet
safety
We must ensure that we have unique access to the alternate set being
swapped.
We must ensure that we have unique access to the alternate set being swapped .