-
public final class ThreadUtilsKt
-
-
Method Summary
Modifier and Type Method Description final static <T extends Any> TensureMainContext(SuspendFunction1<CoroutineScope, T> block)Execute code on the main thread with proper coroutine integration. final static <T extends Any> TwithMainContext(SuspendFunction1<CoroutineScope, T> block)Switch to main thread context. final static <T extends Any> TwithIOContext(SuspendFunction1<CoroutineScope, T> block)Switch to I/O thread context. final static <T extends Any> TwithCPUContext(SuspendFunction1<CoroutineScope, T> block)Switch to CPU thread context. final static <T extends Any> TwithDatabaseContext(SuspendFunction1<CoroutineScope, T> block)Switch to database thread context. -
-
Method Detail
-
ensureMainContext
final static <T extends Any> T ensureMainContext(SuspendFunction1<CoroutineScope, T> block)
Execute code on the main thread with proper coroutine integration.
If already on main thread, executes immediately to avoid unnecessary dispatch.
-
withMainContext
final static <T extends Any> T withMainContext(SuspendFunction1<CoroutineScope, T> block)
Switch to main thread context.
-
withIOContext
final static <T extends Any> T withIOContext(SuspendFunction1<CoroutineScope, T> block)
Switch to I/O thread context.
-
withCPUContext
final static <T extends Any> T withCPUContext(SuspendFunction1<CoroutineScope, T> block)
Switch to CPU thread context.
-
withDatabaseContext
final static <T extends Any> T withDatabaseContext(SuspendFunction1<CoroutineScope, T> block)
Switch to database thread context.
-
-
-
-