Each task is executed in a new thread with a new async runtime
This runtime is dropped (destroyed) when the task exits
Problem
If an instance is started within a task runtime, and since the runtime is destroyed by the end of the task's lifetime, this makes any subsequent access to that instance from the main runtime invalid.
Solution
The solution is to have all instance operation call execute in the 'main' runtime. To achieve this:
[ ] Setup a task that owns a copy of AppState
[ ] Encode the instance operations into an enum, for ex:
enum InstanceOperation {
Start,
Stop,
// more
}
[ ] Encode the result of each instance operation into an enum
[ ] Spawn the task in the 'main' runtime (see database task for example)
[ ] Set up a MPSC channel to pass message into the task
[ ] Set up a ??? channel to pass the result out of the task
[ ] Set up the task so that it receives commands and executes them, and sends out the results
[ ] Build async APIs to abstract the calling process
Preliminary
Each task is executed in a new thread with a new async runtime
Problem
If an instance is started within a task runtime, and since the runtime is destroyed by the end of the task's lifetime, this makes any subsequent access to that instance from the main runtime invalid.
Solution
The solution is to have all instance operation call execute in the 'main' runtime. To achieve this:
AppState