summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/main
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-06-20 22:56:33 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-06-21 12:19:43 +0200
commitd54ac10449083a490e741d6c54e6f3aa07b71af0 (patch)
tree64632acc289887610c8ccd39b4f0aec9515881ef /opendc-simulator/opendc-simulator-compute/src/main
parent4b9559ce78e1853600c816f8228205ddf405c5a2 (diff)
simulator: Remove concept of resource lifecycle
This change removes the AutoCloseable interface from the SimResourceProvider and removes the concept of a resource lifecycle. Instead, resource providers are now either active (running a resource consumer) or in-active (being idle), which simplifies implementation.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src/main')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractHypervisor.kt8
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt5
2 files changed, 6 insertions, 7 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractHypervisor.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractHypervisor.kt
index d24ed1f3..c560cd28 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractHypervisor.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractHypervisor.kt
@@ -129,6 +129,10 @@ public abstract class SimAbstractHypervisor(
override fun close() {
super.close()
+ for (cpu in cpus) {
+ cpu.close()
+ }
+
_vms.remove(this)
}
}
@@ -137,9 +141,9 @@ public abstract class SimAbstractHypervisor(
* A [SimProcessingUnit] of a virtual machine.
*/
private class VCpu(
- private val source: SimResourceProvider,
+ private val source: SimResourceCloseableProvider,
override val model: ProcessingUnit
- ) : SimProcessingUnit, SimResourceProvider by source {
+ ) : SimProcessingUnit, SimResourceCloseableProvider by source {
override var capacity: Double
get() = source.capacity
set(_) {
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt
index 93d306cf..3a70680c 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt
@@ -115,11 +115,6 @@ public abstract class SimAbstractMachine(
isTerminated = true
cancel()
- interpreter.batch {
- for (cpu in cpus) {
- cpu.close()
- }
- }
}
/* SimResourceSystem */