Skip to content

Commit

Permalink
#sửa một số comment
Browse files Browse the repository at this point in the history
  • Loading branch information
phuvh committed Jul 5, 2022
1 parent 531ba74 commit 6a638fd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/kotlin/org/magicghostvu/actor/Behaviors.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.magicghostvu.actor

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.ActorScope
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.channels.actor
Expand All @@ -11,7 +9,6 @@ import org.magicghostvu.actor.timer.DelayedMessage
import org.magicghostvu.actor.timer.SingleTimerData
import org.magicghostvu.actor.timer.TimerManData
import org.magicghostvu.mlogger.ActorLogger
import java.lang.management.ManagementFactory

object Behaviors {

Expand Down Expand Up @@ -41,7 +38,7 @@ object Behaviors {
// theo mặc định khi actor bị crash nó sẽ stop(cancel) scope đã tạo ra actor
// khi actor stop an toàn thì sẽ không affect đến scope ban đầu
// nếu createNewScope = true thì sẽ create một scope mới cho actor kèm với supervisor
// actor crash sẽ không gây stop scope ban đầu
// actor crash sẽ không gây stop scope ban đầu
@OptIn(ObsoleteCoroutinesApi::class)
private fun <T> CoroutineScope.spawn(
debug: Boolean = false,
Expand All @@ -58,6 +55,7 @@ object Behaviors {
}
val internalChannel = scopeSpawnActor.actor<Any>(capacity = 10000) {

Dispatchers.Unconfined

val logger = ActorLogger.logger

Expand Down Expand Up @@ -177,6 +175,9 @@ object Behaviors {
return MActorRef(internalChannel as SendChannel<T>, name)
}

// actor mới này nếu stop an toàn thì không affect đến parent
// nếu crash sẽ gây crash parents
// parents stop sẽ stop tất cả các con
@OptIn(ObsoleteCoroutinesApi::class)
fun <T> ActorScope<*>.spawnChild(
debug: Boolean = false,
Expand Down

0 comments on commit 6a638fd

Please sign in to comment.