Object ThreadController

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • cancelAllNonUICoroutines

         final Unit cancelAllNonUICoroutines()

        This method cancels all coroutines that are children of io and navigator jobs. The call affects all coroutines that where started via ThreadController.ioScope.launch() and ThreadController.navigatorScope.launch(). It is basically a kill switch for all non-UI scoped coroutines.

      • cancelAllUICoroutines

         final Unit cancelAllUICoroutines()

        This method cancels all coroutines that are children of this job. The call affects all coroutines that where started via ThreadController.mainScope.launch(). It is basically a kill switch for all UI scoped coroutines.

      • getIOScopeAndRootJob

         final JobControl getIOScopeAndRootJob()

        This method creates a Job object that is a child of the ioRootJob. Using this job a CoroutineScope is created. The return object is the JobControl data class. This data class contains both the new Job object and the CoroutineScope that uses the Job object. This construct allows the caller to cancel all coroutines created from the returned CoroutineScope. Example: val jobController:JobController = ThreadController.getIOScopeAndRootJob() val job_1 = jobController.ioScope.launch{ doSomethingUsefull_1()} val job_2 = jobController.ioScope.launch{ doSomethingUsefull_2()} val job_3 = jobController.ioScope.launch{ doSomethingUsefull_3()} val job_4 = jobController.ioScope.launch{ doSomethingUsefull_4()}

        The code launches four coroutines. Each one becomes a parent of ThreadController.job To cancel all coroutines: jobController.job.cancel() To cancel a specific coroutine: job_1.cancel(), etc.