Improve event handler coroutine management

This commit is contained in:
Him188 2020-04-29 18:21:01 +08:00
parent 9fdc8cd929
commit a08bf241ed

View File

@ -29,8 +29,8 @@ internal fun <E : Event> Class<E>._subscribeEventForJaptOnly(
): Listener<E> {
return this.kotlin.subscribeInternal(
scope.Handler(
EmptyCoroutineContext,
Listener.ConcurrencyKind.CONCURRENT
scope.coroutineContext,
Listener.ConcurrencyKind.LOCKED
) { withContext(Dispatchers.IO) { onEvent.apply(it) } })
}
@ -39,6 +39,6 @@ internal fun <E : Event> Class<E>._subscribeEventForJaptOnly(scope: CoroutineSco
return this.kotlin.subscribeInternal(
scope.Handler(
EmptyCoroutineContext,
Listener.ConcurrencyKind.CONCURRENT
Listener.ConcurrencyKind.LOCKED
) { withContext(Dispatchers.IO) { onEvent.accept(it) }; ListeningStatus.LISTENING; })
}