From 86c65e875b7dde8872dc81a37aa9dca72eee7782 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 19 Oct 2021 17:27:01 +0200 Subject: refactor(simulator): Support running workloads without coroutines This change updates the SimMachine interface to drop the coroutine requirement for running a workload on a machines. Users can now asynchronously start a workload and receive notifications via the workload callbacks. Users still have the possibility to suspend execution during workload execution by using the new `runWorkload` method, which is implemented on top of the new `startWorkload` primitive. --- .../src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'opendc-faas/opendc-faas-simulator/src') diff --git a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt index 020d75b5..68233c1a 100644 --- a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt +++ b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt @@ -36,6 +36,7 @@ import org.opendc.simulator.compute.SimMachine import org.opendc.simulator.compute.model.MachineModel import org.opendc.simulator.compute.power.ConstantPowerModel import org.opendc.simulator.compute.power.SimplePowerDriver +import org.opendc.simulator.compute.runWorkload import org.opendc.simulator.flow.FlowEngine import java.time.Clock import java.util.ArrayDeque @@ -114,7 +115,7 @@ public class SimFunctionDeployer( override fun close() { state = FunctionInstanceState.Deleted stop() - machine.close() + machine.cancel() } override fun toString(): String = "FunctionInstance[state=$state]" @@ -130,7 +131,7 @@ public class SimFunctionDeployer( launch { try { - machine.run(workload) + machine.runWorkload(workload) } finally { state = FunctionInstanceState.Deleted } -- cgit v1.2.3