turtlestitch/libraries/parallel_module.xml

1 wiersz
3.1 KiB
XML

<blocks app="Snap! 7, https://snap.berkeley.edu" version="2"><block-definition s="do in parallel %&apos;actions&apos; and wait" type="command" category="control"><comment x="0" y="0" w="238.66666666666666" collapsed="false">Accepts any number of scripts as inputs. Launches a separate thread for each of them, so they are done in parallel, then waits for them all to complete.&#xD;&#xD;This doesn&apos;t change how the Snap! scheduler works; the threads are not truly asynchronous. And there is no increase in speed. Rather, the point of this block is to allow starting synchronized but independent scripts.</comment><header></header><code></code><translations>pt:executa _ em paralelo e espera&#xD;ca:executa en paral·lel _ i espera&#xD;</translations><inputs><input type="%mult%cs"></input></inputs><script><block s="doDeclareVariables"><list><l>threads</l></list></block><block s="doSetVar"><l>threads</l><block s="reportMap"><block s="reifyReporter"><autolambda><block s="evaluate"><block s="reifyScript"><script><block s="doDeclareVariables"><list><l>is running?</l></list></block><block s="doSetVar"><l>is running?</l><block s="reportBoolean"><l><bool>true</bool></l></block></block><block s="fork"><block s="reifyScript"><script><block s="doRun"><block var="each script"/><list></list></block><block s="doSetVar"><l>is running?</l><block s="reportBoolean"><l><bool>false</bool></l></block></block></script><list></list></block><list></list></block><block s="doReport"><block s="reifyScript"><script><block s="doReport"><block var="is running?"/></block></script><list></list></block></block></script><list></list></block><list></list></block></autolambda><list><l>each script</l></list></block><block var="actions"/></block></block><block s="doWaitUntil"><block s="reportListIsEmpty"><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="evaluate"><block var="test"/><list></list></block></autolambda><list><l>test</l></list></block><block var="threads"/></block></block></block></script></block-definition><block-definition s="do in parallel %&apos;actions&apos;" type="command" category="control"><comment x="0" y="0" w="238.66666666666666" collapsed="false">Accepts any number of scripts as inputs. Launches a separate thread for each of them, so they are done in parallel, then continues with the current script while they all run.&#xD;&#xD;This doesn&apos;t change how the Snap! scheduler works; the threads are not truly asynchronous. And there is no increase in speed. Rather, the point of this block is to allow starting synchronized but independent scripts.</comment><header></header><code></code><translations>pt:executa _ em paralelo&#xD;ca:executa en paral·lel _&#xD;</translations><inputs><input type="%mult%cs"></input></inputs><script><block s="doIf"><block s="reportGreaterThan"><block s="reportListAttribute"><l><option>length</option></l><block var="actions"/></block><l>0</l></block><script><block s="fork"><block s="reportListItem"><l>1</l><block var="actions"/></block><list></list></block><custom-block s="do in parallel %mult%cs"><block s="reportCDR"><block var="actions"/></block></custom-block></script></block></script></block-definition></blocks>