pub async fn blocking( exec: impl SpawnBlocking ) -> DynResult<()>
{
	let flag  = Arc::new( AtomicBool::new( false ) );
	let flag2 = flag.clone();

	let task = move ||
	{
		// blocking work
		//
		std::thread::sleep( Duration::from_millis( 5 ) );

		flag2.store( true, SeqCst );
	};

	let handle = exec.spawn_blocking( task );

	handle.await;

	assert!( flag.load(SeqCst) );

	Ok(())
}
// Use same exec to run this function as you pass in.
//
Use same exec to run this function as you pass in.
Use same exec to run this function as you pass in .
pub async fn blocking( exec: impl SpawnBlocking ) -> DynResult<()>
{
	let flag  = Arc::new( AtomicBool::new( false ) );
	let flag2 = flag.clone();
	let task = move ||
	{
		// blocking work
		//
		std::thread::sleep( Duration::from_millis( 5 ) );
		flag2.store( true, SeqCst );
	};
	let handle = exec.spawn_blocking( task );
	handle.await;
	assert!( flag.load(SeqCst) );
	Ok(())
}
pub async fn blocking ( exec : impl SpawnBlocking ) -> DynResult < ( ) > { let flag = Arc :: new ( AtomicBool :: new ( false ) ) ; let flag2 = flag . clone ( ) ; let task = move | | { // blocking work // std :: thread :: sleep ( Duration :: from_millis ( 5 ) ) ; flag2 . store ( true , SeqCst ) ; } ; let handle = exec . spawn_blocking ( task ) ; handle . await ; assert ! ( flag load ( SeqCst ) ) ; Ok ( ( ) ) }
Use same exec to run this function as you pass in.
Use same exec to run this function as you pass in .
exec
impl SpawnBlocking
exec
impl SpawnBlocking