fn with_capacity(cap: usize) -> Self {
        let handoff = if cap == 0 { Some(Event::new()) } else { None };
        let cap = cap.max(1);

        // Compute constants `mark_bit` and `one_lap`.
        let mark_bit = (cap + 1).next_power_of_two();
        let one_lap = mark_bit * 2;

        // Head is initialized to `{ lap: 0, mark: 0, index: 0 }`.
        let head = 0;
        // Tail is initialized to `{ lap: 0, mark: 0, index: 0 }`.
        let tail = 0;

        // Allocate a buffer of `cap` slots.
        let buffer = {
            let mut v = Vec::<Slot<T>>::with_capacity(cap);
            let ptr = v.as_mut_ptr();
            mem::forget(v);
            ptr
        };

        // Initialize stamps in the slots.
        for i in 0..cap {
            unsafe {
                // Set the stamp to `{ lap: 0, mark: 0, index: i }`.
                let slot = buffer.add(i);
                ptr::write(&mut (*slot).stamp, AtomicUsize::new(i));
            }
        }

        Channel {
            buffer,
            cap,
            one_lap,
            mark_bit,
            head: AtomicUsize::new(head),
            tail: AtomicUsize::new(tail),
            send_ops: Event::new(),
            sink_ops: Event::new(),
            handoff,
            recv_ops: Event::new(),
            next_ops: Event::new(),
            sender_count: AtomicUsize::new(1),
            receiver_count: AtomicUsize::new(1),
            _marker: PhantomData,
        }
    }
/// Creates a bounded channel of capacity `cap`.
Creates a bounded channel of capacity `cap`.
Creates a bounded channel of capacity ` cap ` .
fn with_capacity(cap: usize) -> Self {
        let handoff = if cap == 0 { Some(Event::new()) } else { None };
        let cap = cap.max(1);
        // Compute constants `mark_bit` and `one_lap`.
        let mark_bit = (cap + 1).next_power_of_two();
        let one_lap = mark_bit * 2;
        // Head is initialized to `{ lap: 0, mark: 0, index: 0 }`.
        let head = 0;
        // Tail is initialized to `{ lap: 0, mark: 0, index: 0 }`.
        let tail = 0;
        // Allocate a buffer of `cap` slots.
        let buffer = {
            let mut v = Vec::<Slot<T>>::with_capacity(cap);
            let ptr = v.as_mut_ptr();
            mem::forget(v);
            ptr
        };
        // Initialize stamps in the slots.
        for i in 0..cap {
            unsafe {
                // Set the stamp to `{ lap: 0, mark: 0, index: i }`.
                let slot = buffer.add(i);
                ptr::write(&mut (*slot).stamp, AtomicUsize::new(i));
            }
        }
        Channel {
            buffer,
            cap,
            one_lap,
            mark_bit,
            head: AtomicUsize::new(head),
            tail: AtomicUsize::new(tail),
            send_ops: Event::new(),
            sink_ops: Event::new(),
            handoff,
            recv_ops: Event::new(),
            next_ops: Event::new(),
            sender_count: AtomicUsize::new(1),
            receiver_count: AtomicUsize::new(1),
            _marker: PhantomData,
        }
    }
fn with_capacity ( cap : usize ) -> Self { let handoff = if cap == 0 { Some ( Event :: new ( ) ) } else { None } ; let cap = cap . max ( 1 ) ; // Compute constants `mark_bit` and `one_lap`. let mark_bit = ( cap + 1 ) . next_power_of_two ( ) ; let one_lap = mark_bit * 2 ; // Head is initialized to `{ lap: 0, mark: 0, index: 0 }`. let head = 0 ; // Tail is initialized to `{ lap: 0, mark: 0, index: 0 }`. let tail = 0 ; // Allocate a buffer of `cap` slots. let buffer = { let mut v = Vec :: < Slot < T > > :: with_capacity ( cap ) ; let ptr = v . as_mut_ptr ( ) ; mem :: forget ( v ) ; ptr } ; // Initialize stamps in the slots. for i in 0 .. cap { unsafe { // Set the stamp to `{ lap: 0, mark: 0, index: i }`. let slot = buffer . add ( i ) ; ptr :: write ( & mut ( * slot ) . stamp , AtomicUsize :: new ( i ) ) ; } } Channel { buffer , cap , one_lap , mark_bit , head : AtomicUsize :: new ( head ) , tail : AtomicUsize :: new ( tail ) , send_ops : Event :: new ( ) , sink_ops : Event :: new ( ) , handoff , recv_ops : Event :: new ( ) , next_ops : Event :: new ( ) , sender_count : AtomicUsize :: new ( 1 ) , receiver_count : AtomicUsize :: new ( 1 ) , _marker : PhantomData , } }
Creates a bounded channel of capacity `cap`.
Creates a bounded channel of capacity ` cap ` .
cap
usize