Hello, I am the author of the GHAsync Plugin. For more information about the plug-in, please see the page on food4rhino. I won’t go into it here.
Basically, the asynchronous component runs by doing nothing more than creating background tasks on the first input of data. Background tasks calling back to expire asynchronous component when they all complete, to complete the output of the data.
Now I’ve discovered a strange problem. When a async component is contained in a cluster, output of cluster is always delayed by one solution?
For example, in this pic, I need to update cluster’s input twice to get the correct output from the first input.
If you look at how clusters work, they always run once, regardless of the data structure you give them, it’s not like a normal component that synchronizes the data structure based on parameter access, cluster parameters work like tree access, so from the parent document context, the first input data means all its data. This could be saying that clusters can only call SolveInstance() once per solution. But you need to expire the cluster with each new input, and that eliminates the previous outputs, so you would have to cache the previous results and overwrite the final result by putting each of them together.
It may be due to something else, the clusters don’t run Anemone or Kangaroo as normal either, it could be related. GH is designed to run sequentially, a solution must be completed in order to update the status of a component.
Is your plugin aware that the document may be the document of a cluster? because you may be referencing the parent document instead of the cluster document. GH_Document.Owner can be a GH_Cluster. And if not, you must handle this recursively, because clusters can contain other clusters.
You need to do a recursive computation on the internal cluster document, to fully boost it; otherwise the internal document would be executed synchronously. Cluster has a different mechanism from Hops.
I was about to release a parallelized GH solver. Guess I shall cancel it.
ps: Oh it seems your component is replaced to allow for async computation, which is different from my implementation. Your approach is more natural to CLR’s Task model.
I’m sorry I didn’t quite understand your suggestion. Could you provide some more information? Thanks.
When I was debugging the program, I did find that the GH_ActiveObject.ExpireSolution(true) method in the component itself does not work in the cluster. Do you mean that I need to expire the cluster component which the async components in after all the asynchronous components have been computed?
Also, thank you for your praise, but everyone has the right to publish their work freely, so look forward to your plugins.