From: Tuukka Lehtonen Date: Mon, 29 Jan 2018 13:54:46 +0000 (+0200) Subject: Added syncActivateModel function for deterministic SCL script execution X-Git-Tag: v1.43.0~136^2~616 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=a0c282689925d3b29dbb5239426163decc61689d Added syncActivateModel function for deterministic SCL script execution syncActivateModel works directly by invoking the old activeModel function and then waiting until all related activities are finished by using the old trusty Simantics/Misc/syncGraph function. refs #7730 Change-Id: Ib75bc3c33e1dcf6b5c46d61dffdcd106f451730a --- diff --git a/bundles/org.simantics.modeling/scl/Simantics/Model.scl b/bundles/org.simantics.modeling/scl/Simantics/Model.scl index c631d399e..e82975e67 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/Model.scl +++ b/bundles/org.simantics.modeling/scl/Simantics/Model.scl @@ -1,5 +1,6 @@ include "Simantics/Entity" hiding (nameOf) include "Simantics/Ontologies" +import "Simantics/Misc" type Model = Resource type Configuration = Resource @@ -50,6 +51,13 @@ importJava "org.simantics.modeling.ModelingUtils" where searchByTypeAndFilter :: Resource -> Resource -> (Resource -> Boolean) -> [Resource] listIndexEntries :: Resource -> String -> String + + """ + Activates the specified model but does not wait for any of the effects + caused by the activation to be completed. In most cases the blocking + version [syncActivateModel](#syncActivateModel) should be used instead + of this function. + """ activateModel :: Resource -> Boolean @JavaName createModel @@ -64,5 +72,21 @@ activateModelAction :: Resource -> () activateModelAction model = do syncWrite (\() -> activateModel model) () - - \ No newline at end of file + +""" +Activates the specified model and blocks until all effects caused by the +activation have been completed. This function is a synchronous version of +the older [activateModel](#activateModel) function that does not wait for +activation completion, i.e. works asynchronously. In most cases it is +recommended to use this functions instead of + +The effect completion waiting works based on the `org.simantics.db.service.ServiceActivityMonitor` +service offered by the database client. Therefore implementation that want +to support waiting for activation completion need to register/unregister +activities with this service accordingly. +""" +syncActivateModel :: Resource -> Boolean +syncActivateModel model = do + result = syncWrite (\() -> activateModel model) + syncGraph () + result \ No newline at end of file