summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorContext.kt1
-rw-r--r--odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorPath.kt4
-rw-r--r--odcsim-engine-omega/src/main/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystem.kt19
-rw-r--r--odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemContract.kt2
-rw-r--r--odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/BehaviorTestKitImpl.kt6
-rw-r--r--odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/TestInboxImpl.kt9
6 files changed, 23 insertions, 18 deletions
diff --git a/odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorContext.kt b/odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorContext.kt
index b43a1bab..3a704f32 100644
--- a/odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorContext.kt
+++ b/odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorContext.kt
@@ -120,4 +120,3 @@ interface ActorContext<T : Any> {
*/
fun isSync(target: ActorRef<*>): Boolean
}
-
diff --git a/odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorPath.kt b/odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorPath.kt
index cc3b19af..f51a4fed 100644
--- a/odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorPath.kt
+++ b/odcsim-core/src/main/kotlin/com/atlarge/odcsim/ActorPath.kt
@@ -65,7 +65,7 @@ sealed class ActorPath : Comparable<ActorPath>, Serializable {
require(name.length == 1 || name.indexOf('/', 1) == -1) {
"/ may only exist at the beginning of the root actors name"
}
- require(name.indexOf('#') == -1) { "# may not exist in a path component"}
+ require(name.indexOf('#') == -1) { "# may not exist in a path component" }
}
override val parent: ActorPath = this
@@ -95,7 +95,7 @@ sealed class ActorPath : Comparable<ActorPath>, Serializable {
data class Child(override val parent: ActorPath, override val name: String) : ActorPath() {
init {
require(name.indexOf('/') == -1) { "/ may not exist in a path component" }
- require(name.indexOf('#') == -1) { "# may not exist in a path component"}
+ require(name.indexOf('#') == -1) { "# may not exist in a path component" }
}
override val root: Root by lazy {
diff --git a/odcsim-engine-omega/src/main/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystem.kt b/odcsim-engine-omega/src/main/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystem.kt
index 7e58084d..c1d487b7 100644
--- a/odcsim-engine-omega/src/main/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystem.kt
+++ b/odcsim-engine-omega/src/main/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystem.kt
@@ -88,8 +88,8 @@ class OmegaActorSystem<in T : Any>(root: Behavior<T>, override val name: String)
// Start the root actor on initial run
if (state == ActorSystemState.CREATED) {
- registry[path]!!.isolate { it.start() }
state = ActorSystemState.STARTED
+ registry[path]!!.isolate { it.start() }
} else if (state == ActorSystemState.TERMINATED) {
throw IllegalStateException("The ActorSystem has been terminated.")
}
@@ -106,6 +106,7 @@ class OmegaActorSystem<in T : Any>(root: Behavior<T>, override val name: String)
queue.poll()
val actor = registry[envelope.destination] ?: continue
+
// Notice that messages for unknown/terminated actors are ignored for now
actor.isolate { it.interpretMessage(envelope.message) }
}
@@ -249,8 +250,10 @@ class OmegaActorSystem<in T : Any>(root: Behavior<T>, override val name: String)
/**
* Internal [ActorRef] implementation for this actor system.
*/
- private data class ActorRefImpl<T : Any>(private val owner: OmegaActorSystem<*>,
- override val path: ActorPath) : ActorRef<T> {
+ private data class ActorRefImpl<T : Any>(
+ private val owner: OmegaActorSystem<*>,
+ override val path: ActorPath
+ ) : ActorRef<T> {
override fun toString(): String = "Actor[$path]"
override fun compareTo(other: ActorRef<*>): Int = path.compareTo(other.path)
@@ -264,10 +267,12 @@ class OmegaActorSystem<in T : Any>(root: Behavior<T>, override val name: String)
* @property time The point in time to deliver the message.
* @property message The message to wrap.
*/
- private class EnvelopeImpl(val id: Long,
- val destination: ActorPath,
- override val time: Instant,
- override val message: Any) : Envelope<Any>
+ private class EnvelopeImpl(
+ val id: Long,
+ val destination: ActorPath,
+ override val time: Instant,
+ override val message: Any
+ ) : Envelope<Any>
/**
* Schedule a message to be processed by the engine.
diff --git a/odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemContract.kt b/odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemContract.kt
index bdcfad55..cb75c2ac 100644
--- a/odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemContract.kt
+++ b/odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemContract.kt
@@ -169,7 +169,6 @@ abstract class ActorSystemContract {
system.terminate()
}
-
@Nested
@DisplayName("ActorRef")
inner class ActorRefTest {
@@ -346,7 +345,6 @@ abstract class ActorSystemContract {
system.terminate()
}
-
/**
* Test whether an actor that is crashed cannot receive more messages.
*/
diff --git a/odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/BehaviorTestKitImpl.kt b/odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/BehaviorTestKitImpl.kt
index 5b6669bb..cb216614 100644
--- a/odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/BehaviorTestKitImpl.kt
+++ b/odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/BehaviorTestKitImpl.kt
@@ -40,8 +40,10 @@ import kotlin.math.max
* @param initialBehavior The initial behavior to initialize the actor of the test kit with.
* @param path The path to the actor.
*/
-internal class BehaviorTestKitImpl<T : Any>(initialBehavior: Behavior<T>,
- path: ActorPath) : BehaviorTestKit<T> {
+internal class BehaviorTestKitImpl<T : Any>(
+ initialBehavior: Behavior<T>,
+ path: ActorPath
+) : BehaviorTestKit<T> {
/**
* The [BehaviorInterpreter] used to interpret incoming messages.
*/
diff --git a/odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/TestInboxImpl.kt b/odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/TestInboxImpl.kt
index 2f939eaa..35abd758 100644
--- a/odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/TestInboxImpl.kt
+++ b/odcsim-testkit/src/main/kotlin/com/atlarge/odcsim/testkit/internal/TestInboxImpl.kt
@@ -84,9 +84,11 @@ internal class TestInboxImpl<T : Any>(private val owner: BehaviorTestKitImpl<*>,
* @property time The point in time to deliver the message.
* @property message The message to wrap.
*/
- private inner class EnvelopeImpl(val id: Long,
- override val time: Instant,
- override val message: T) : Envelope<T> {
+ private inner class EnvelopeImpl(
+ val id: Long,
+ override val time: Instant,
+ override val message: T
+ ) : Envelope<T> {
override fun compareTo(other: Envelope<*>): Int {
val cmp = super.compareTo(other)
return if (cmp == 0 && other is EnvelopeImpl)
@@ -95,5 +97,4 @@ internal class TestInboxImpl<T : Any>(private val owner: BehaviorTestKitImpl<*>,
cmp
}
}
-
}