Skip to content

Instantly share code, notes, and snippets.

@GauravChaddha1996
Created January 30, 2021 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GauravChaddha1996/2a1a3923113f7bf61844c41ce3bade80 to your computer and use it in GitHub Desktop.
Save GauravChaddha1996/2a1a3923113f7bf61844c41ce3bade80 to your computer and use it in GitHub Desktop.
/**
* @return a job to represent the coroutine for 'T'
* */
fun taskT(): Job {
/*
* Starting task 'T' by launching coroutine 'C'
*
* Task name: T
* Coroutine name: C
* Thread pool: IO is used since we do network calls etc.
* Scope: We use global scope since the operation is to be
completed even if the page closes.
* Builder explanation: launch builder is used since it is a
fire and forget task the calling page doesn't care about
it's result.
* suspension: No this won't block the main thread but simply
start 'C'.
*
* We return the representative job.
* */
return GlobalScope.launch(Dispatchers.IO) {
// Logic binding code for t1, t2, t3, t4 and
// t5 is omitted here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment