diff --git a/src/main/java/li/cil/oc2/api/bus/device/rpc/RPCDevice.java b/src/main/java/li/cil/oc2/api/bus/device/rpc/RPCDevice.java index f88ccb72..fc2773e3 100644 --- a/src/main/java/li/cil/oc2/api/bus/device/rpc/RPCDevice.java +++ b/src/main/java/li/cil/oc2/api/bus/device/rpc/RPCDevice.java @@ -17,6 +17,39 @@ import java.util.List; *
* The easiest, and hence recommended, way of implementing this interface, is to use * the {@link ObjectDevice} class. + *
+ * The lifecycle for {@link RPCDevice}s is as follows: + *
+ * ┌──────────────────────────────────┐ + * │VirtualMachine.isRunning() = false◄──────────────────────┐ + * └────────────────┬─────────────────┘ │ + * │ │ + * ┌──────────▼───────────┐ │ + * │VirtualMachine.start()│ │ + * └──────────┬───────────┘ │ + * │ │ + * │ ┌──────────┐ │ + * │ │Chunk Load│ ┌──────────────────┐ │ + * ├───┼──────────◄────┤VMDevice.suspend()│ │ + * │ │World Load│ └─────▲────────────┘ │ + * │ └──────────┘ │ │ + * │ │ │ + * ┌────────▼───────┐ ┌─────┴──────┐ │ + * ┌──────────►VMDevice.mount()│ │Chunk Unload│ │ + * │ └────────┬───────┘ ┌─►────────────┤ │ + * │ │ │ │World Unload│ │ + * │ ┌─────────────────▼───────────────┐ │ └────────────┘ │ + * │ │VirtualMachine.isRunning() = true├─┤ │ + * │ └─────┬───────────────────┬───────┘ │ ┌──────────────────┐ │ + * │ │ │ │ │Computer Shutdown │ │ + * │ ┌─────▼──────┐ ┌──────▼───────┐ └─►──────────────────┤ │ + * └─┤Device Added│ │Device Removed│ │Computer Destroyed│ │ + * └────────────┘ └──────┬───────┘ └─────┬────────────┘ │ + * │ │ │ + * ┌────────▼─────────┐ ┌─────▼────────────┐ │ + * │VMDevice.unmount()│ │VMDevice.unmount()├─┘ + * └──────────────────┘ └──────────────────┘ + ** * @see ObjectDevice * @see li.cil.oc2.api.bus.device.provider.BlockDeviceProvider diff --git a/src/main/java/li/cil/oc2/api/bus/device/vm/VMDevice.java b/src/main/java/li/cil/oc2/api/bus/device/vm/VMDevice.java index 4e31be1d..7de911f6 100644 --- a/src/main/java/li/cil/oc2/api/bus/device/vm/VMDevice.java +++ b/src/main/java/li/cil/oc2/api/bus/device/vm/VMDevice.java @@ -16,6 +16,56 @@ import li.cil.sedna.api.device.MemoryMappedDevice; *
* To listen to lifecycle events of the VM and the device, register to the event * bus provided via {@link VMContext#getEventBus()} in {@link #mount(VMContext)}. + *
+ * The lifecycle for VMDevices can be depicted as such: + *
+ * ┌──────────────────────────────────┐ + * │VirtualMachine.isRunning() = false◄────────────────────────┐ + * └────────────────┬─────────────────┘ │ + * │ │ + * ┌──────────▼───────────┐ │ + * │VirtualMachine.start()│ │ + * └──────────┬───────────┘ │ + * │ │ + * │ ┌──────────┐ │ + * │ │Chunk Load│ ┌──────────────────┐ │ + * ├───┼──────────◄──┤VMDevice.suspend()◄───┐ │ + * │ │World Load│ └──────────────────┘ │ │ + * │ └──────────┘ │ │ + * │ │ │ + * ┌────────▼───────┐ ┌────┐ │ │ + * ┌──────────►VMDevice.mount()◄───────┤Wait◄─────────┐ │ │ + * │ └────────┬───────┘ └──▲─┘ │ │ │ + * │ │ │ │ │ │ + * │ │ ┌───────────────┴─────────┐ │ │ │ + * │ ├──►VMDeviceLoadResult.fail()│ │ │ │ + * │ │ └─────────────────────────┘ │ │ │ + * │ │ │ │ │ + * │ ┌──────────────▼─────────────┐ ┌──────────────┴───┐ │ │ + * │ │VMDeviceLoadResult.success()│ │VMDevice.unmount()│ │ │ + * │ └──────────────┬─────────────┘ └──────────────▲───┘ │ │ + * │ │ │ │ │ + * │ │ ┌─────────────────────┴───┐ │ │ + * │ ├────────► Other VMDevice: │ │ │ + * │ │ │VMDeviceLoadResult.fail()│ │ │ + * │ │ └─────────────────────────┘ │ │ + * │ │ │ │ + * │ │ ┌────────────┐ │ │ + * │ │ │Chunk Unload│ │ │ + * │ │ ┌─►────────────┼─────┘ │ + * │ │ │ │World Unload│ │ + * │ ┌─────────────────▼───────────────┐ │ └────────────┘ │ + * │ │VirtualMachine.isRunning() = true├───┤ │ + * │ └─────┬───────────────────┬───────┘ │ ┌──────────────────┐ │ + * │ │ │ │ │Computer Shutdown │ │ + * │ ┌─────▼──────┐ ┌──────▼───────┐ └─►──────────────────┤ │ + * └─┤Device Added│ │Device Removed│ │Computer Destroyed│ │ + * └────────────┘ └──────┬───────┘ └─────────┬────────┘ │ + * │ │ │ + * ┌────────▼─────────┐ ┌─────────▼────────┐ │ + * │VMDevice.unmount()│ │VMDevice.unmount()├─┘ + * └──────────────────┘ └──────────────────┘ + ** * @see li.cil.oc2.api.bus.device.provider.BlockDeviceProvider * @see li.cil.oc2.api.bus.device.provider.ItemDeviceProvider