diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2017-09-21 23:25:44 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2017-09-21 23:25:44 +0200 |
| commit | a031db367c71ec1604b34f3765198c2196bfe551 (patch) | |
| tree | 793c4af1a9b0c4f8bbc0d901b2a8ae90ac22d4ee /opendc-core | |
| parent | 735d5543ed72f0c6cf632b35b3f23323cebcf81b (diff) | |
Create simple datacenter experiment
Diffstat (limited to 'opendc-core')
| -rw-r--r-- | opendc-core/src/main/kotlin/nl/atlarge/opendc/extension/topology/Traversable.kt (renamed from opendc-core/src/main/kotlin/nl/atlarge/opendc/extension/Node.kt) | 2 | ||||
| -rw-r--r-- | opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/extension/Node.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/extension/topology/Traversable.kt index 83100587..b5b5ec82 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/extension/Node.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/extension/topology/Traversable.kt @@ -22,7 +22,7 @@ * SOFTWARE. */ -package nl.atlarge.opendc.extension +package nl.atlarge.opendc.extension.topology import nl.atlarge.opendc.topology.Edge diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt index 46cb271e..6185e273 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt @@ -33,6 +33,7 @@ import nl.atlarge.opendc.topology.Entity import nl.atlarge.opendc.topology.Topology import nl.atlarge.opendc.topology.TopologyContext import java.lang.Process +import java.util.* /** * This interface provides a context for simulation [Process]es, which defines the environment in which the simulation @@ -87,7 +88,7 @@ interface Context<out E : Entity<*>> : Readable, Writable, TopologyContext { /** * Suspend the [Process] of the [Entity] in simulation for the given duration of simulation time before resuming - * execution. + * execution and drop all messages that are received during this period. * * A call to this method will not make the [Process] sleep for the actual duration of time, but instead suspend * the process until the no more messages at an earlier point in time have to be processed. @@ -97,6 +98,18 @@ interface Context<out E : Entity<*>> : Readable, Writable, TopologyContext { suspend fun wait(duration: Duration) /** + * Suspend the [Process] of the [Entity] in simulation for the given duration of simulation time before resuming + * execution and push all messages that are received during this period to the given queue. + * + * A call to this method will not make the [Process] sleep for the actual duration of time, but instead suspend + * the process until the no more messages at an earlier point in time have to be processed. + * + * @param duration The duration of simulation time to wait before resuming execution. + * @param queue The mutable queue to push the messages to. + */ + suspend fun wait(duration: Duration, queue: Queue<Any>) + + /** * Suspend the [Process] of the [Entity] in simulation for one tick in simulation time which is defined by the * [Clock]. * |
