| | 121 | === Avoiding Two-phase Initialization === |
| | 122 | |
| | 123 | If a directed graph of the data dependences has no cycles, |
| | 124 | then it can be serialized in an order such that when it is deserialized, |
| | 125 | all of the referenced data will exist before it is needed. |
| | 126 | That requirement, we assert, holds for anything in the Chimera2 core. |
| | 127 | And we can detect when it is violated, |
| | 128 | and report to the user what the offending toolor tools are. |
| | 129 | |
| | 130 | ==== Saving Protocol ==== |
| | 131 | |
| | 132 | 1. Discovery |
| | 133 | * All state is reachable from the session object |
| | 134 | * The initial set objects to save in the session are the session's registered state attributes |
| | 135 | * Objects to save are examined for referred to non-simple objects, and those objects are added to the set of savable objects, until all objects are examined |
| | 136 | * These are the objects that need to be named symbolically |
| | 137 | * Simple objects are ints, lists, dicts, etc. |
| | 138 | * While examining savable objects: |
| | 139 | * dependency graph is constructed |
| | 140 | * the set of needed tools is constructed |
| | 141 | * Detect "all" cycles, so user can take corrective action if there are cycles |
| | 142 | 2. Serializing |
| | 143 | * The list of needed tools and their session state versions |
| | 144 | * The data in sorted order |
| | 145 | |
| | 146 | ==== Restoring Protocol ==== |
| | 147 | |
| | 148 | 1. Get list of needed tools |
| | 149 | * If installed tools are insufficient, allow user to install them |
| | 150 | * If not installed, don't restore data from those tools, might fail |
| | 151 | 2. Clear main session |
| | 152 | 3. Restore into main session while blocking triggers |
| | 153 | |