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

	let task = async move
	{
		flag2.store( true, SeqCst );
	};

	let handle = exec.spawn_handle( task )?;

	// glommio will only yield if we have been running sufficiently long.
	//
	#[ cfg( feature = "glommio" ) ]
	//
	std::thread::sleep( Duration::from_millis( 20 ) );


	exec.yield_now().await;

	// by now task should have run because of the yield_now.
	//
	assert!( flag.load(SeqCst) );

	handle.await;

	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 try_yield_now( exec: impl SpawnHandle<()> + YieldNow ) -> DynResult<()>
{
	let flag  = Arc::new( AtomicBool::new( false ) );
	let flag2 = flag.clone();
	let task = async move
	{
		flag2.store( true, SeqCst );
	};
	let handle = exec.spawn_handle( task )?;
	// glommio will only yield if we have been running sufficiently long.
	//
	#[ cfg( feature = "glommio" ) ]
	//
	std::thread::sleep( Duration::from_millis( 20 ) );
	exec.yield_now().await;
	// by now task should have run because of the yield_now.
	//
	assert!( flag.load(SeqCst) );
	handle.await;
	Ok(())
}
pub async fn try_yield_now ( exec : impl SpawnHandle < ( ) > + YieldNow ) -> DynResult < ( ) > { let flag = Arc :: new ( AtomicBool :: new ( false ) ) ; let flag2 = flag . clone ( ) ; let task = async move { flag2 . store ( true , SeqCst ) ; } ; let handle = exec . spawn_handle ( task ) ? ; // glommio will only yield if we have been running sufficiently long. // # [ cfg ( feature " " ) ] // std :: thread :: sleep ( Duration :: from_millis ( 20 ) ) ; exec . yield_now ( ) . await ; // by now task should have run because of the yield_now. // assert ! ( flag load ( SeqCst ) ) ; handle . await ; 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 SpawnHandle<()> + YieldNow
exec
impl SpawnHandle<()> + YieldNow