pub fn new(transport: TransportArc) -> Self {
        let queue = Arc::new(Mutex::new(Vec::new()));
        #[allow(clippy::mutex_atomic)]
        let shutdown = Arc::new((Mutex::new(false), Condvar::new()));

        let worker_transport = transport.clone();
        let worker_queue = queue.clone();
        let worker_shutdown = shutdown.clone();
        let worker = std::thread::Builder::new()
            .name("sentry-session-flusher".into())
            .spawn(move || {
                let (lock, cvar) = worker_shutdown.as_ref();
                let mut shutdown = lock.lock().unwrap();
                // check this immediately, in case the main thread is already shutting down
                if *shutdown {
                    return;
                }
                let mut last_flush = Instant::now();
                loop {
                    let timeout = FLUSH_INTERVAL - last_flush.elapsed();
                    shutdown = cvar.wait_timeout(shutdown, timeout).unwrap().0;
                    if *shutdown {
                        return;
                    }
                    if last_flush.elapsed() < FLUSH_INTERVAL {
                        continue;
                    }
                    SessionFlusher::flush(worker_queue.lock().unwrap(), &worker_transport);
                    last_flush = Instant::now();
                }
            })
            .unwrap();

        Self {
            transport,
            queue,
            shutdown,
            worker: Some(worker),
        }
    }
/// Creates a new Flusher that will submit envelopes to the given `transport`.
Creates a new Flusher that will submit envelopes to the given `transport`.
Creates a new Flusher that will submit envelopes to the given ` transport ` .
pub fn new(transport: TransportArc) -> Self {
        let queue = Arc::new(Mutex::new(Vec::new()));
        #[allow(clippy::mutex_atomic)]
        let shutdown = Arc::new((Mutex::new(false), Condvar::new()));
        let worker_transport = transport.clone();
        let worker_queue = queue.clone();
        let worker_shutdown = shutdown.clone();
        let worker = std::thread::Builder::new()
            .name("sentry-session-flusher".into())
            .spawn(move || {
                let (lock, cvar) = worker_shutdown.as_ref();
                let mut shutdown = lock.lock().unwrap();
                // check this immediately, in case the main thread is already shutting down
                if *shutdown {
                    return;
                }
                let mut last_flush = Instant::now();
                loop {
                    let timeout = FLUSH_INTERVAL - last_flush.elapsed();
                    shutdown = cvar.wait_timeout(shutdown, timeout).unwrap().0;
                    if *shutdown {
                        return;
                    }
                    if last_flush.elapsed() < FLUSH_INTERVAL {
                        continue;
                    }
                    SessionFlusher::flush(worker_queue.lock().unwrap(), &worker_transport);
                    last_flush = Instant::now();
                }
            })
            .unwrap();
        Self {
            transport,
            queue,
            shutdown,
            worker: Some(worker),
        }
    }
pub fn new ( transport : TransportArc ) -> Self { let queue = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ; # [ allow ( clippy mutex_atomic ) ] let shutdown = Arc :: new ( ( Mutex :: new ( false ) , Condvar :: new ( ) ) ) ; let worker_transport = transport . clone ( ) ; let worker_queue = queue . clone ( ) ; let worker_shutdown = shutdown . clone ( ) ; let worker = std :: thread :: Builder :: new ( ) . name ( " " . into ( ) ) . spawn ( move | | { let ( lock , cvar ) = worker_shutdown . as_ref ( ) ; let mut shutdown = lock . lock ( ) . unwrap ( ) ; // check this immediately, in case the main thread is already shutting down if * shutdown { return ; } let mut last_flush = Instant :: now ( ) ; loop { let timeout = FLUSH_INTERVAL - last_flush . elapsed ( ) ; shutdown = cvar . wait_timeout ( shutdown , timeout ) . unwrap ( ) . 0 ; if * shutdown { return ; } if last_flush . elapsed ( ) < FLUSH_INTERVAL { continue ; } SessionFlusher :: flush ( worker_queue . lock ( ) . unwrap ( ) , & worker_transport ) ; last_flush = Instant :: now ( ) ; } } ) . unwrap ( ) ; Self { transport , queue , shutdown , worker : Some ( worker ) , } }
Creates a new Flusher that will submit envelopes to the given `transport`.
Creates a new Flusher that will submit envelopes to the given ` transport ` .
transport
TransportArc