-
@RestrictTo(value = {RestrictTo.Scope.LIBRARY_GROUP}) public class ThreadUtils
Thread management utilities for the CloudX SDK.
Provides optimized thread pools and executors for different types of operations, ensuring efficient resource usage and proper thread lifecycle management.
-
-
Field Summary
Fields Modifier and Type Field Description private final CoroutineDispatcherMainDispatcherprivate final CoroutineDispatcherIODispatcherpublic final static ThreadUtilsINSTANCE
-
Method Summary
Modifier and Type Method Description final CoroutineScopecreateMainScope(String tag)Convenience method to create a main-thread component scope (uses Main dispatcher). final CoroutineScopecreateIOScope(String tag)Convenience method to create a background component scope (uses IO dispatcher). final UnitrunOnMain(Function0<Unit> block)Run block on the main thread. final CoroutineDispatchergetMainDispatcher()final CoroutineDispatchergetIODispatcher()-
-
Method Detail
-
createMainScope
final CoroutineScope createMainScope(String tag)
Convenience method to create a main-thread component scope (uses Main dispatcher). Use for UI-related components like ad managers, UI controllers, etc.
-
createIOScope
final CoroutineScope createIOScope(String tag)
Convenience method to create a background component scope (uses IO dispatcher). Use for background components like trackers, network managers, etc.
-
runOnMain
final Unit runOnMain(Function0<Unit> block)
Run block on the main thread. Executes inline if already on main, otherwise posts to the main looper via a cached Handler.
-
getMainDispatcher
final CoroutineDispatcher getMainDispatcher()
-
getIODispatcher
final CoroutineDispatcher getIODispatcher()
-
-
-
-