mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 12:14:04 +08:00
[core] CoroutineOnDemandValueScope: ignore multiple finishImpl
This commit is contained in:
parent
e76cdfb5df
commit
1b122190f1
@ -99,7 +99,7 @@ internal class CoroutineOnDemandValueScope<T, V>(
|
|||||||
private fun finishImpl(exception: Throwable?) {
|
private fun finishImpl(exception: Throwable?) {
|
||||||
state.loop { state ->
|
state.loop { state ->
|
||||||
when (state) {
|
when (state) {
|
||||||
is ProducerState.Finished -> throw state.createAlreadyFinishedException(exception)
|
is ProducerState.Finished -> {} // ignore
|
||||||
else -> {
|
else -> {
|
||||||
if (compareAndSetState(state, ProducerState.Finished(state, exception))) {
|
if (compareAndSetState(state, ProducerState.Finished(state, exception))) {
|
||||||
val cancellationException = kotlinx.coroutines.CancellationException("Finished", exception)
|
val cancellationException = kotlinx.coroutines.CancellationException("Finished", exception)
|
||||||
@ -153,6 +153,7 @@ internal class CoroutineOnDemandValueScope<T, V>(
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> throw IllegalProducerStateException(state)
|
else -> throw IllegalProducerStateException(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user