Switchable

可开关的。

此接口提供 startcancel 等相关开始、关闭的操作。

对于开关操作,在执行了 cancel 之后将不允许二次开启。

Author

ForteScarlet

Functions

Link copied to clipboard
abstract suspend fun cancel(reason: Throwable? = null): Boolean

关闭操作.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun delay(duration: JavaDuration, runnable: Runnable): DelayableCompletableFuture<Void?>

延时 duration 时间后执行回调函数 runnable,得到一个 DelayableCompletableFuture

open fun delay(millis: Long, runnable: Runnable): DelayableCompletableFuture<Void?>

延迟 millis 毫秒后执行 runnable,得到一个 DelayableCompletableFuture

open fun delay(time: Long, timeUnit: TimeUnit, runnable: Runnable): DelayableCompletableFuture<Void?>

延迟时间单位为 timeUnittime 时长后执行 runnable,得到一个 DelayableCompletableFuture

Link copied to clipboard

延迟 duration 时间后,执行 supplier, 并将 supplier 得到结果通过得到的 DelayableCompletableFuture 向下传递。

open fun <V> delayAndCompute(millis: Long, supplier: Supplier<V>): DelayableCompletableFuture<V>

延迟 millis 毫秒的时长后执行 supplier, 并将 supplier 得到结果通过得到的 DelayableCompletableFuture 向下传递。

open fun <V> delayAndCompute(time: Long, timeUnit: TimeUnit, supplier: Supplier<V>): DelayableCompletableFuture<V>

延迟时间单位为 timeUnittime 时长后执行 supplier, 并将 supplier 得到结果通过得到的 DelayableCompletableFuture 向下传递。

Link copied to clipboard
abstract suspend fun start(): Boolean

启动操作.

Properties

Link copied to clipboard
Link copied to clipboard
abstract val isActive: Boolean

是否正在运行,即启动后尚未关闭。

Link copied to clipboard
abstract val isCancelled: Boolean

是否已经被取消。

Link copied to clipboard
abstract val isStarted: Boolean

是否已经启动过了。

Inheritors

Link copied to clipboard

Extensions

Link copied to clipboard
fun <A : Application> CoroutineScope.applicationLauncher(create: suspend () -> A): ApplicationLauncher<A>

通过一个协程作用域并提供构建函数来得到一个 ApplicationLauncher 实例。

Link copied to clipboard
inline fun <T> CoroutineScope.effectedFlowItems(crossinline block: suspend FlowCollector<T>.() -> Unit): Items<T>

以构建 Flow 的方式构建 Items.

Link copied to clipboard
inline fun <T> CoroutineScope.effectedItemsByFlow(crossinline flowFactory: () -> Flow<T>): Items<T>

提供 CoroutineScope 和构建 Flow 的函数 flowFactory 来构建 Items.

Link copied to clipboard
inline fun <T> CoroutineScope.flowItems(crossinline block: suspend FlowCollector<T>.(Items.PreprocessingProperties) -> Unit): Items<T>

以构建 Flow 的方式构建 Items.

Link copied to clipboard
inline fun <T> CoroutineScope.itemsByFlow(crossinline flowFactory: (Items.PreprocessingProperties) -> Flow<T>): Items<T>

提供 CoroutineScope 和构建 Flow 的函数 flowFactory 来构建 Items.

Link copied to clipboard
fun <T> CoroutineScope.lazyValue(init: Boolean = false, initializer: suspend () -> T): LazyValue<T>
Link copied to clipboard
inline fun <T> CoroutineScope.produceItems(context: CoroutineContext = EmptyCoroutineContext, capacity: Int = 0, crossinline block: suspend ProducerScope<T>.(Items.PreprocessingProperties) -> Unit): Items<T>

通过 produce 构建 ChannelIterator 来得到一个 Items 实例。