From 5b48cdbad2493c7af9e79bb9996f195ace3123e5 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 6 May 2019 15:44:56 +0200 Subject: style: Format code according to Ktlint style guide This change formats the code according to the style guide of Ktlint. --- .../main/kotlin/com/atlarge/odcsim/ActorContext.kt | 1 - .../src/main/kotlin/com/atlarge/odcsim/ActorPath.kt | 4 ++-- .../atlarge/odcsim/engine/omega/OmegaActorSystem.kt | 19 ++++++++++++------- .../odcsim/engine/tests/ActorSystemContract.kt | 2 -- .../odcsim/testkit/internal/BehaviorTestKitImpl.kt | 6 ++++-- .../atlarge/odcsim/testkit/internal/TestInboxImpl.kt | 9 +++++---- 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 { */ 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, 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, 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(root: Behavior, 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(root: Behavior, 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(root: Behavior, override val name: String) /** * Internal [ActorRef] implementation for this actor system. */ - private data class ActorRefImpl(private val owner: OmegaActorSystem<*>, - override val path: ActorPath) : ActorRef { + private data class ActorRefImpl( + private val owner: OmegaActorSystem<*>, + override val path: ActorPath + ) : ActorRef { override fun toString(): String = "Actor[$path]" override fun compareTo(other: ActorRef<*>): Int = path.compareTo(other.path) @@ -264,10 +267,12 @@ class OmegaActorSystem(root: Behavior, 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 + private class EnvelopeImpl( + val id: Long, + val destination: ActorPath, + override val time: Instant, + override val message: Any + ) : Envelope /** * 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(initialBehavior: Behavior, - path: ActorPath) : BehaviorTestKit { +internal class BehaviorTestKitImpl( + initialBehavior: Behavior, + path: ActorPath +) : BehaviorTestKit { /** * 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(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 { + private inner class EnvelopeImpl( + val id: Long, + override val time: Instant, + override val message: T + ) : Envelope { 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(private val owner: BehaviorTestKitImpl<*>, cmp } } - } -- cgit v1.2.3