/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 2 1 ĠR ick ĠBus ar ow Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ @ file : Suppress (" Deferred Is Result ") Ċ Ċ package Ġdispatch . core Ċ Ċ import Ġkotlinx . coroutines .* Ċ import Ġkotlin . coroutines .* Ċ Ċ /** Ċ Ġ* ĠCreates Ġa Ġcoroutine Ġand Ġreturns Ġits Ġfuture Ġresult Ġas Ġan Ġimplementation Ġof Ġ[ Deferred ]. Ċ Ġ* Ċ Ġ* ĠExtract s Ġthe Ġ[ Dispatcher Provider ] Ġfrom Ġthe Ġ[ Coroutine Scope ] Ġreceiver , Ġthen Ġuses Ġits Ġ** default ** Ġ[ Coroutine Dispatcher ] Ċ Ġ* Ġproperty Ġ(` coroutine Context . dispatcher Provider . default `) Ġto Ġcall Ġ` async (...) `. Ċ Ġ* Ċ Ġ* ĠThe Ġ` default ` Ġproperty Ġalways Ġcorresponds Ġto Ġthe Ġ` Dispatcher Provider ` Ġof Ġthe Ġcurrent Ġ` Coroutine Scope `. Ċ Ġ* Ċ Ġ* Ġ@ sample Ġdispatch . core . samples . Async Sample . async Default Sample Ċ Ġ* Ġ@ see Ġasync Ċ Ġ*/ Ċ public Ġfun Ġ< T > ĠCor outine Scope . async Default ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġstart : ĠCor outine Start Ġ= ĠCor outine Start . DEFAULT , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠDeferred < T > Ġ= Ġasync ( context Ġ+ Ġcoroutine Context . dispatcher Provider . default , Ġstart , Ġblock ) Ċ Ċ /** Ċ Ġ* ĠCreates Ġa Ġcoroutine Ġand Ġreturns Ġits Ġfuture Ġresult Ġas Ġan Ġimplementation Ġof Ġ[ Deferred ]. Ċ Ġ* Ċ Ġ* ĠExtract s Ġthe Ġ[ Dispatcher Provider ] Ġfrom Ġthe Ġ[ Coroutine Scope ] Ġreceiver , Ġthen Ġuses Ġits Ġ** io ** Ġ[ Coroutine Dispatcher ] Ċ Ġ* Ġproperty Ġ(` coroutine Context . dispatcher Provider . io `) Ġto Ġcall Ġ` async (...) `. Ċ Ġ* Ċ Ġ* ĠThe Ġ` io ` Ġproperty Ġalways Ġcorresponds Ġto Ġthe Ġ` Dispatcher Provider ` Ġof Ġthe Ġcurrent Ġ` Coroutine Scope `. Ċ Ġ* Ċ Ġ* Ġ@ sample Ġdispatch . core . samples . Async Sample . async IO Sample Ċ Ġ* Ġ@ see Ġasync Ċ Ġ*/ Ċ public Ġfun Ġ< T > ĠCor outine Scope . async IO ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġstart : ĠCor outine Start Ġ= ĠCor outine Start . DEFAULT , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠDeferred < T > Ġ= Ġasync ( context Ġ+ Ġcoroutine Context . dispatcher Provider . io , Ġstart , Ġblock ) Ċ Ċ /** Ċ Ġ* ĠCreates Ġa Ġcoroutine Ġand Ġreturns Ġits Ġfuture Ġresult Ġas Ġan Ġimplementation Ġof Ġ[ Deferred ]. Ċ Ġ* Ċ Ġ* ĠExtract s Ġthe Ġ[ Dispatcher Provider ] Ġfrom Ġthe Ġ[ Coroutine Scope ] Ġreceiver , Ġthen Ġuses Ġits Ġ** main ** Ġ[ Coroutine Dispatcher ] Ċ Ġ* Ġproperty Ġ(` coroutine Context . dispatcher Provider . main `) Ġto Ġcall Ġ` async (...) `. Ċ Ġ* Ċ Ġ* ĠThe Ġ` main ` Ġproperty Ġalways Ġcorresponds Ġto Ġthe Ġ` Dispatcher Provider ` Ġof Ġthe Ġcurrent Ġ` Coroutine Scope `. Ċ Ġ* Ċ Ġ* Ġ@ sample Ġdispatch . core . samples . Async Sample . async Main Sample Ċ Ġ* Ġ@ see Ġasync Ċ Ġ*/ Ċ public Ġfun Ġ< T > ĠCor outine Scope . async Main ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġstart : ĠCor outine Start Ġ= ĠCor outine Start . DEFAULT , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠDeferred < T > Ġ= Ġasync ( context Ġ+ Ġcoroutine Context . dispatcher Provider . main , Ġstart , Ġblock ) Ċ Ċ /** Ċ Ġ* ĠCreates Ġa Ġcoroutine Ġand Ġreturns Ġits Ġfuture Ġresult Ġas Ġan Ġimplementation Ġof Ġ[ Deferred ]. Ċ Ġ* Ċ Ġ* ĠExtract s Ġthe Ġ[ Dispatcher Provider ] Ġfrom Ġthe Ġ[ Coroutine Scope ] Ġreceiver , Ġthen Ġuses Ġits Ġ** main Immediate ** Ġ[ Coroutine Dispatcher ] Ċ Ġ* Ġproperty Ġ(` coroutine Context . dispatcher Provider . main Immediate `) Ġto Ġcall Ġ` async (...) `. Ċ Ġ* Ċ Ġ* ĠThe Ġ` main Immediate ` Ġproperty Ġalways Ġcorresponds Ġto Ġthe Ġ` Dispatcher Provider ` Ġof Ġthe Ġcurrent Ġ` Coroutine Scope `. Ċ Ġ* Ċ Ġ* Ġ@ sample Ġdispatch . core . samples . Async Sample . async Main Immediate Sample Ċ Ġ* Ġ@ see Ġasync Ċ Ġ*/ Ċ public Ġfun Ġ< T > ĠCor outine Scope . async Main Immediate ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġstart : ĠCor outine Start Ġ= ĠCor outine Start . DEFAULT , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠDeferred < T > Ġ= Ġasync ( context Ġ+ Ġcoroutine Context . dispatcher Provider . main Immediate , Ġstart , Ġblock ) Ċ Ċ /** Ċ Ġ* ĠCreates Ġa Ġcoroutine Ġand Ġreturns Ġits Ġfuture Ġresult Ġas Ġan Ġimplementation Ġof Ġ[ Deferred ]. Ċ Ġ* Ċ Ġ* ĠExtract s Ġthe Ġ[ Dispatcher Provider ] Ġfrom Ġthe Ġ[ Coroutine Scope ] Ġreceiver , Ġthen Ġuses Ġits Ġ** un conf ined ** Ġ[ Coroutine Dispatcher ] Ċ Ġ* Ġproperty Ġ(` coroutine Context . dispatcher Provider . un conf ined `) Ġto Ġcall Ġ` async (...) `. Ċ Ġ* Ċ Ġ* ĠThe Ġ` un conf ined ` Ġproperty Ġalways Ġcorresponds Ġto Ġthe Ġ` Dispatcher Provider ` Ġof Ġthe Ġcurrent Ġ` Coroutine Scope `. Ċ Ġ* Ċ Ġ* Ġ@ sample Ġdispatch . core . samples . Async Sample . async Un conf ined Sample Ċ Ġ* Ġ@ see Ġasync Ċ Ġ*/ Ċ public Ġfun Ġ< T > ĠCor outine Scope . async Un conf ined ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġstart : ĠCor outine Start Ġ= ĠCor outine Start . DEFAULT , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠDeferred < T > Ġ= Ġasync ( context Ġ+ Ġcoroutine Context . dispatcher Provider . un conf ined , Ġstart , Ġblock ) Ċ