6
$\begingroup$

I have a question deriving from a recent topic Synchronizing Dynamics with EventActions.

tl;dr;

How to authoritatively explain the influence of SynchronousUpdating->False on behaviour of Dynamic[x, ...] after clicking Button["test", x = 1; FinishDynamic[]; Pause[1]; x = 2 ].

Background

[...] There is no queue; instead, the front end sends one evaluation at a time and waits for the result before continuing with its other work, [...] the front end is completely locked up, [...]

-- Synchronous versus Asynchronous Dynamic Evaluations about the PreemptiveLink

That is why, x here, won't be updated till the whole expression is evaluated (x=2).

Dynamic[x]

   (*We are deliberately ignoring Method->"Queued" to show the point*)
Button["test", x = 1; Pause[1]; x = 2 ]

We can use FinishDynamic[] (more in link at the top) to ask the FrontEnd to update all Dynamics. When FinishDynamic[] returns the Kernel can proceed with Pause and the rest.

 Button["test", x = 1; FinishDynamic[]; Pause[1]; x = 2 ]

It will only affect synchronous (default) Dynamics though. e.g. Dynamic[x, SynchronousUpdating -> False] won't be triggered.

The question

This brought me to the conclusion that the MainLink (asynchronous Dynamics) can't be used by a FrontEnd when a preemptive evaluation is going on (even if it is waiting for FinishDynamic[] to return).

Is that correct? Are there any official sources confirming that? Maybe it can be deduced from Dynamic related tutorials?

Loose thoughts

From what I understand, MainLink evaluations are only sent (by FE to K) when the Kernel is "free", till then they are queued by a FrontEnd.

Mathematica knows that in this case waiting has no sense since the Kernel is waiting for the FinishDynamic[] and the FrontEnd would wait for Dynamic content evaluation.

That is why there isn't even such thing like UpdateDynamicObjectsAsynchronous, it would always end up in an infinite waiting from both sides.

Does it make sense?

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.