Add lifecycle flowchart to RPCDevice and VMDevice docs.
This commit is contained in:
@@ -17,6 +17,39 @@ import java.util.List;
|
||||
* <p>
|
||||
* The easiest, and hence recommended, way of implementing this interface, is to use
|
||||
* the {@link ObjectDevice} class.
|
||||
* <p>
|
||||
* The lifecycle for {@link RPCDevice}s is as follows:
|
||||
* <pre>
|
||||
* ┌──────────────────────────────────┐
|
||||
* │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()├─┘
|
||||
* └──────────────────┘ └──────────────────┘
|
||||
* </pre>
|
||||
*
|
||||
* @see ObjectDevice
|
||||
* @see li.cil.oc2.api.bus.device.provider.BlockDeviceProvider
|
||||
|
||||
@@ -16,6 +16,56 @@ import li.cil.sedna.api.device.MemoryMappedDevice;
|
||||
* <p>
|
||||
* 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)}.
|
||||
* <p>
|
||||
* The lifecycle for VMDevices can be depicted as such:
|
||||
* <pre>
|
||||
* ┌──────────────────────────────────┐
|
||||
* │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()├─┘
|
||||
* └──────────────────┘ └──────────────────┘
|
||||
* </pre>
|
||||
*
|
||||
* @see li.cil.oc2.api.bus.device.provider.BlockDeviceProvider
|
||||
* @see li.cil.oc2.api.bus.device.provider.ItemDeviceProvider
|
||||
|
||||
Reference in New Issue
Block a user