pub fn new(
        test_name: String,
        duration: std::time::Duration,
        sender: mpsc::Sender<TestEvent>,
        max_capacity: usize,
    ) -> Self {
        let inner = LogBufferInner::new(test_name, sender, max_capacity);
        let timer = fuchsia_async::Timer::new(duration);
        let log_buffer = Arc::downgrade(&inner);
        let f = async move {
            timer.await;
            if let Some(log_buffer) = log_buffer.upgrade() {
                let mut log_buffer = log_buffer.lock().await;
                if let Err(e) = log_buffer.stop_buffering().await {
                    log_buffer.set_error(e);
                }
            }
        };

        let timer = fuchsia_async::Task::spawn(f);

        Self { inner, timer }
    }
/// Crates new LogBuffer and starts the timer on log buffering.
/// `duration`: Buffers log for this duration or till done() is called.
/// `sender`: Channel to send logs on.
/// `max_capacity`: Flush log if buffer size exceeds this value. This will not cancel the timer
/// and all the logs would be flushed once timer expires.
Crates new LogBuffer and starts the timer on log buffering.
`duration`: Buffers log for this duration or till done() is called.
`sender`: Channel to send logs on.
`max_capacity`: Flush log if buffer size exceeds this value. This will not cancel the timer
and all the logs would be flushed once timer expires.
Crates new LogBuffer and starts the timer on log buffering . ` duration ` : Buffers log for this duration or till done () is called . ` sender ` : Channel to send logs on . ` max_capacity ` : Flush log if buffer size exceeds this value . This will not cancel the timer and all the logs would be flushed once timer expires .
pub fn new(
        test_name: String,
        duration: std::time::Duration,
        sender: mpsc::Sender<TestEvent>,
        max_capacity: usize,
    ) -> Self {
        let inner = LogBufferInner::new(test_name, sender, max_capacity);
        let timer = fuchsia_async::Timer::new(duration);
        let log_buffer = Arc::downgrade(&inner);
        let f = async move {
            timer.await;
            if let Some(log_buffer) = log_buffer.upgrade() {
                let mut log_buffer = log_buffer.lock().await;
                if let Err(e) = log_buffer.stop_buffering().await {
                    log_buffer.set_error(e);
                }
            }
        };
        let timer = fuchsia_async::Task::spawn(f);
        Self { inner, timer }
    }
pub fn new ( test_name : String , duration : std :: time :: Duration , sender : mpsc :: Sender < TestEvent > , max_capacity : usize , ) -> Self { let inner = LogBufferInner :: new ( test_name , sender , max_capacity ) ; let timer = fuchsia_async :: Timer :: new ( duration ) ; let log_buffer = Arc :: downgrade ( & inner ) ; let f = async move { timer . await ; if let Some ( log_buffer ) = log_buffer . upgrade ( ) { let mut log_buffer = log_buffer . lock ( ) . await ; if let Err ( e ) = log_buffer . stop_buffering ( ) . await { log_buffer . set_error ( e ) ; } } } ; let timer = fuchsia_async :: Task :: spawn ( f ) ; Self { inner , timer } }
Crates new LogBuffer and starts the timer on log buffering.
Crates new LogBuffer and starts the timer on log buffering .
test_name
String
duration
std::time::Duration
sender
mpsc::Sender<TestEvent>
max_capacity
usize
test_name
String
duration
std::time::Duration
sender
mpsc::Sender<TestEvent>
max_capacity
usize