[−][src]Function minus::async_std_updating
pub async fn async_std_updating(mutex: Lines)
Initialize a updating pager inside a async_std task
This function is only available when async_std_lib
feature is enabled
It takes a Lines
and updates the page with new information when Lines
is updated
This function switches to the Alternate Screen
of the TTY and
switches to raw mode
Example
use std::sync::{Arc, Mutex}; use futures::join; use std::time::Duration; #[async_std::main] async fn main() { let output = Arc::new(Mutex::new(String::new())); let push_data = async { for i in 1..=100 { let mut guard = output.lock().unwrap(); guard.push_str(&i.to_string()); // If you have furthur asynchronous blocking code, drop the borrow here drop(guard); // Some asynchronous blocking code async_std::task::sleep(Duration::new(1,0)).await; } }; join!(minus::async_std_updating(output.clone()), push_data); }
Please do note that you should never lock the output data, since this will cause the paging thread to be paused. Only borrow it when it is required and drop it if you have furthur asynchronous blocking code