diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2018-10-28 12:50:27 +0100 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2019-05-06 18:19:23 +0200 |
| commit | decb8fb5297c7772f5319a47c784d44bf8bdbe9c (patch) | |
| tree | 4151b2ffe1b99a3bfe91a8fd1b7dfeade91a5ec0 /opendc-stdlib/src/main/kotlin/com/atlarge/opendc/simulator/Helpers.kt | |
| parent | d37a139b357ded9ba048c10ccad320a0d8412f0b (diff) | |
refactor: Introduce initial API design for 2.x
This change introduces the new API design that will be introduced in the
2.x versions of the OpenDC Simulator.
This changes focuses on simplifying simulation primitives provided by
the simulator and introduces a new concept of actors based on the model
designed by the Akka Typed project.
For now, the old simulation models have been removed from the branch,
but will be ported back as this branch is being finalized.
Diffstat (limited to 'opendc-stdlib/src/main/kotlin/com/atlarge/opendc/simulator/Helpers.kt')
| -rw-r--r-- | opendc-stdlib/src/main/kotlin/com/atlarge/opendc/simulator/Helpers.kt | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/opendc-stdlib/src/main/kotlin/com/atlarge/opendc/simulator/Helpers.kt b/opendc-stdlib/src/main/kotlin/com/atlarge/opendc/simulator/Helpers.kt deleted file mode 100644 index 0f6392ed..00000000 --- a/opendc-stdlib/src/main/kotlin/com/atlarge/opendc/simulator/Helpers.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.atlarge.opendc.simulator - -import kotlin.coroutines.experimental.intrinsics.suspendCoroutineOrReturn - -/** - * Try to find the [Context] instance associated with the [Process] in the call chain which has (indirectly) invoked the - * caller of this method. - * - * Note however that this method does not guarantee type-safety as this method allows the user to cast to a context - * with different generic type arguments. - * - * @return The context that has been found or `null` if this method is not called in a simulation context. - */ -suspend fun <S, M> contextOrNull(): Context<S, M>? = suspendCoroutineOrReturn { it.context[Context] } - -/** - * Find the [Context] instance associated with the [Process] in the call chain which has (indirectly) invoked the - * caller of this method. - * - * Note however that this method does not guarantee type-safety as this method allows the user to cast to a context - * with different generic type arguments. - * - * @throws IllegalStateException if the context cannot be found. - * @return The context that has been found. - */ -suspend fun <S, M> context(): Context<S, M> = - contextOrNull() ?: throw IllegalStateException("The suspending call does not have an associated process context") - -/** - * Try to find the untyped [Context] instance associated with the [Process] in the call chain which has (indirectly) - * invoked the caller of this method. - * - * @return The untyped context that has been found or `null` if this method is not called in a simulation context. - */ -suspend fun untypedContextOrNull(): Context<*, *>? = contextOrNull<Any?, Any?>() - -/** - * Find the [Context] instance associated with the [Process] in the call chain which has (indirectly) invoked the - * caller of this method. - * - * @throws IllegalStateException if the context cannot be found. - * @return The untyped context that has been found. - */ -suspend fun untypedContext(): Context<*, *> = context<Any?, Any?>() |
