Commit f51790e7 authored by Him188's avatar Him188

Add EventScope

parent 4d09010c
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
package net.mamoe.mirai.event package net.mamoe.mirai.event
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import net.mamoe.mirai.event.internal.broadcastInternal import net.mamoe.mirai.event.internal.broadcastInternal
/** /**
...@@ -50,4 +53,6 @@ interface Cancellable { ...@@ -50,4 +53,6 @@ interface Cancellable {
*/ */
@Synchronized @Synchronized
@Suppress("UNCHECKED_CAST") @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() }
\ No newline at end of file
object EventScope : CoroutineScope by CoroutineScope(Dispatchers.Default)//todo may change
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment