en:toolworks:docs:apparatus:deferred

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revisionBoth sides next revision
en:toolworks:docs:apparatus:deferred [2022/06/01 20:05] vladiusen:toolworks:docs:apparatus:deferred [2022/06/05 21:40] vladius
Line 58: Line 58:
 </code> </code>
  
 +====== Applying =====
 +
 +Until when? This is quite a logical question when dealing with something that is deferred by design. And the default answer is "when the time is right". That essentially means that the behavior is automatic by default, i.e. when the corresponding Mechanism's Chain gets disposed and the current active state is non-Solid.
 +
 +The default automatic behavior minimizes the effort and guarantees that the Deferreds get applied accordingly, but maybe you would like to have more control on when and where the application is happening. This is exactly why the concept of //Deferreds Applicators// was introduced.
 +
 +Deferreds Applicators are created explicitly, by calling the [[appi>class_a_mechanism.html#ac658045eedfb7def7bd238dae45cc676|UMechanism::CreateDeferredsApplicator]] method as in:<code cpp>
 +{ // Start of the explicit scope.
 + auto Applicator = Mechanism->CreateDeferredsApplicator();
 + Mechanism->EnchainSolid(...)->OperateConcurrently([](){
 + // Your first mechanic producing deferred operations.
 + });
 + // The Deferreds won't be applied at this point.
 + Mechanism->EnchainSolid(...)->OperateConcurrently([](){
 + // Your second mechanic producing deferred operations. 
 + });
 + // Now the Deferreds get actually applied.
 +} // End of the explicit scope.
 +</code>
 +
 +Note that the Applicator is actually introduced within its own explicit scope (the curly brace'd region). That is in fact done on purpose since the Applicator will apply the pending changes right when it is destroyed, which is guaranteed by ''Applicator'' being a local (automatic) variable and the ''{}'' scope.
  • en/toolworks/docs/apparatus/deferred.txt
  • Last modified: 2022/06/08 22:06
  • by jispar