Programming and Execution Model¶
In this section, we present the programming and execution model of dSpace. Developers create a digi by specifying its model schema and programming the driver. The driver consists of event handlers that are invoked in response to model updates, executing the digi’s embedded policies. dSpace simplifies digi development via a driver programming library, described in this section, and dSpace controllers (§5).
在本节中,我们介绍 dSpace 的编程与执行模型。开发者通过指定 digi 的模型架构并编写驱动程序来创建 digi。驱动程序由事件处理器组成,这些处理器在模型更新时被触发,以执行 digi 的嵌入式策略。dSpace 通过驱动程序编程库(详见本节)和 dSpace 控制器(详见 §5)简化了 digi 的开发流程。
Model Specification and Driver Programming¶
How to use
Detailed Info
整个DIGI view是一堆digi形成的topology,这里面每个digi都是一个独立的个体,我们的每个代码只能作用于相应的个体。
因此我们的代码只需要注重个体的构建,集体通信等问题由runtime来解决(后面会提及)。
- Filters Field: decides when a handler should be called
- Views Field: provides convenient transformations of the model
- Views can be chained.
- Updates to a view will be automatically applied to the source view it is transformed from.
Driver Execution¶
As depicted in Fig.4, the driver starts when digi.run()
is called. It creates a reconciler, registers handlers with the reconciler, and starts watching for changes in the model.
The reconciler is a single process that executes the handlers in order during a reconciliation cycle.
When handlers are registered, they are sorted by their priority values. High priority handlers will be executed later than the low priority ones.
If the list of handlers are updated (i.e., via the reflex API), the order will be updated accordingly.
A handler will be executed only if its model changes satisfy the condition specified in the filter. A reconciliation cycle is triggered whenever there is a new update to the model, unless the update is caused by the previous reconciliation.
Once all handlers are executed, the reconciler writes the updated model to the apiserver.