fn flush(mut queue_lock: MutexGuard<Vec<SessionUpdate<'static>>>, transport: &TransportArc) {
        let queue: Vec<_> = std::mem::take(queue_lock.as_mut());
        drop(queue_lock);

        if queue.is_empty() {
            return;
        }

        let mut envelope = Envelope::new();
        let mut items = 0;

        for session_update in queue {
            if items >= MAX_SESSION_ITEMS {
                if let Some(ref transport) = *transport.read().unwrap() {
                    transport.send_envelope(envelope);
                }
                envelope = Envelope::new();
                items = 0;
            }
            envelope.add_item(session_update);
            items += 1;
        }

        if let Some(ref transport) = *transport.read().unwrap() {
            transport.send_envelope(envelope);
        }
    }
/// Flushes the queue to the transport.
///
/// This is a static method as it will be called from both the background
/// thread and the main thread on drop.
Flushes the queue to the transport.
This is a static method as it will be called from both the background
thread and the main thread on drop.
Flushes the queue to the transport . This is a static method as it will be called from both the background thread and the main thread on drop .
fn flush(mut queue_lock: MutexGuard<Vec<SessionUpdate<'static>>>, transport: &TransportArc) {
        let queue: Vec<_> = std::mem::take(queue_lock.as_mut());
        drop(queue_lock);
        if queue.is_empty() {
            return;
        }
        let mut envelope = Envelope::new();
        let mut items = 0;
        for session_update in queue {
            if items >= MAX_SESSION_ITEMS {
                if let Some(ref transport) = *transport.read().unwrap() {
                    transport.send_envelope(envelope);
                }
                envelope = Envelope::new();
                items = 0;
            }
            envelope.add_item(session_update);
            items += 1;
        }
        if let Some(ref transport) = *transport.read().unwrap() {
            transport.send_envelope(envelope);
        }
    }
fn flush ( mut queue_lock : MutexGuard < Vec < SessionUpdate < ' static > > > , transport : & TransportArc ) { let queue : Vec < _ > = std :: mem :: take ( queue_lock . as_mut ( ) ) ; drop ( queue_lock ) ; if queue . is_empty ( ) { return ; } let mut envelope = Envelope :: new ( ) ; let mut items = 0 ; for session_update in queue { if items >= MAX_SESSION_ITEMS { if let Some ( ref transport ) = * transport . read ( ) . unwrap ( ) { transport . send_envelope ( envelope ) ; } envelope = Envelope :: new ( ) ; items = 0 ; } envelope . add_item ( session_update ) ; items += 1 ; } if let Some ( ref transport ) = * transport . read ( ) . unwrap ( ) { transport . send_envelope ( envelope ) ; } }
Flushes the queue to the transport.
Flushes the queue to the transport .
queue_lock
MutexGuard<Vec<SessionUpdate<'static>>>
transport
&TransportArc