sting-ioc / sting

Home Page:https://sting-ioc.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider supporting concurrent construction within injectors in the JRE

realityforge opened this issue · comments

The synchronized keyword on node accessors results in component creates being limited to one create at a time. This has been sufficient so far as typically components are created at startup and do not perform much work so serializing this activity has little to no impact. It also has zero impact in the single-threaded browser environment.

Eager nodes: For eager nodes we could attempt to create each isolated subtree of eager nodes in parallel where we break the work into multiple tasks for each isolated subtree.

Lazy nodes: We could create a separate lock per node and lock it on entrance to the accessor for lazy components. When creating a component we could order the calls to node accessors for dependencies based on the depth of dependency in injector tree (and thus have a stable fixed order of lock acquisition). This would enable concurrent creation of objects within the graph. We could even make this code generation to support this optional based on a @Injector.concurrent parameter.

However until we have a clear use case in a JRE that actually requires parallel or concurrent construction of the injector, we should defer this work.