Hi Peer,
re:
> From old forum posts it sounds like there were some complications around loose objects
> that have since been solved. Is there anything that I need to know now about async factories
> when using them in a script?
Yes there used to be an issue that the id of an object was generated when it was added to the geometry database. So if you used factory.calculate() to generate some geometry but never add it into the geometry database then it would not have an id value and ids are needed for factories that do async updates.
In v4 this was solved by generating object id values right when the object is initially created, so there isn't a situation anymore where an object doesn't have an id value set on it.
> There's a function .waitForAsyncUpdate() associated with calcarea, calclength, and calcvolume.
> Does that have anything to do with "asynchronous factories", or is that a whole other kind of
> thing specific to just those 3 factories?
The .waitForAsyncUpdate() function is part of the base geometry factory class so it can be used on any factory.
It's used internally by calcCurveLength(), calcSurfaceArea(), and calcSolidVolume() because these needed to return a number value, not an object list and so they use factory.update() followed by waitForAsyncUpdate() because factory.update() can also transmit back modified input values.
> It seems like "asynchronous factories" generate an objectList in the normal way, rather than filling in an input slot.
It depends on how you call the factory, if you call factory.update(), that does not directly return an object list. If you use factory.calculate() , that one does return an object list and it will be generated in process, not sent to moi_commandprocessor for async operation.
In v5 you can request for .calculate() to use remote processing by passing a string option 'async' like: .calculate( 'async' ); . if you do that it will internally block using .waitForAsyncUpdate().
When a factory is using remote processing it gathers up parameters and sends it to a separate moi_commandprocessor process and does the actual work over there. That has the expense of some additional transmission overhead but long running operations can be canceled and there is also crash protection where if the processing crashes it will only take down the worker process and not the main Moi process.
- Michael
|