Skip to content

Commit

Permalink
Add a mcCoroutineDispatcher value
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkmar committed May 20, 2021
1 parent 941be54 commit 5fbbc6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package net.axay.fabrik.core.task

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.*

/**
* A CoroutineScope using the current MinecraftServer
* A [CoroutineDispatcher] which executes code synchronously to the
* MinecraftServer main thread.
*/
lateinit var mcCoroutineDispatcher: CoroutineDispatcher
internal set

/**
* A [CoroutineScope] using the current MinecraftServer
* as the Dispatcher.
*/
lateinit var mcCoroutineScope: CoroutineScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents
object FabrikCoroutineManager {
fun init() {
ServerLifecycleEvents.SERVER_STARTING.register {
mcCoroutineScope = CoroutineScope(it.asCoroutineDispatcher())
mcCoroutineDispatcher = it.asCoroutineDispatcher()
mcCoroutineScope = CoroutineScope(mcCoroutineDispatcher)
logInfo("Initialized mcCoroutineScope")
}
}
Expand Down

0 comments on commit 5fbbc6c

Please sign in to comment.