mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 17:20:11 +08:00
Add EventScope
This commit is contained in:
parent
4d09010cf0
commit
f51790e79b
@ -2,6 +2,9 @@
|
||||
|
||||
package net.mamoe.mirai.event
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import net.mamoe.mirai.event.internal.broadcastInternal
|
||||
|
||||
/**
|
||||
@ -50,4 +53,6 @@ interface Cancellable {
|
||||
*/
|
||||
@Synchronized
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun <E : Event> E.broadcast(): E = this.broadcastInternal()
|
||||
suspend fun <E : Event> E.broadcast(): E = withContext(EventScope.coroutineContext) { this@broadcast.broadcastInternal() }
|
||||
|
||||
object EventScope : CoroutineScope by CoroutineScope(Dispatchers.Default)//todo may change
|
Loading…
Reference in New Issue
Block a user