<div class="chlinkprevnexttop"> <a href="chap0.html">[Top of Book]</a> <a href="chap0<><code =func>askResult<code < href=chap1.#X7A86C732823E04B6"><span class="RefLink">1.2-11</span></a>) does an implicit <code class="func">WaitTask</code> (<a href="chap1.html#X861BC1488345C424"><span class="RefLink">1.2-9</span></a>), so the second line above can actually be omitted:</p>
<id" =>a "h"[ ]/a></>
<p><a ids classGAPprompt>gt<span>sclass""()/java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
<divclass""a=chap1.#X7EA285468533E153">1 <span class="Heading">Tasks</span></a>
<div class="ContSect"><< class=GAPpromptg&;/ span =G> =RunTaskP 5001..10000);/java.lang.StringIndexOutOfBoundsException: Index 111 out of bounds for length 111
<>
</div>
<div class="
</</pre>divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
divclass"">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap1.html#X7DEC1649841E3813">1.2-1 RunTask</a></span>
<class">br >span class">nbsp;<span<href=h
<span class="ContSS"><class"">><span span ">ask1 =(,[.5000);</java.lang.StringIndexOutOfBoundsException: Index 109 out of bounds for length 109
< >spanclass">nbsp;n<span>ahref=h
<span class="ContSS"><br /><span class="nocss<pan =">apgt<span>sclass=GAPinput>aitTasktask1 task2);/spanjava.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92
< class=ContSS"><br ><pan =nocss"&;&bsp;/>a href".#X791CA0E07B16E7F9">1.2-6 MakeTaskAsync</a></span>
<span class="ContSS"><brjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
<pan class="ContSS"<r/<class"ocss>nbsp;nbsp<span>a =chap1.#X83D2E32C8759FB37">1.2-8 ExecuteTask</a></span>
<span classjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
span class"ContSS">br /<class=nocss>nbsp&bsp<span><href".tml
<span class="ContSS"><br /><span class=
<panclass=ContSS>br/>span =nocss"> nbsp;/span>a =chap1.tml#X830A82A7847993FF">1.2-12 CullIdleTasks</a></span>
</div></java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
div class""< =tocline">span class="ocss>nbsp;/>ahref=chap1.html#X86F8419B7968345B">1.3 <span class="Heading">Information about tasks</span></a>
<span
<div [ 1, 2,3]
<</pre/>
<span classjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
< class"ontSS"><r/<panclass=nocss">&bsp;nbsp<span>ahref=chap1.tml#X7C0C66E37DB9ACC0">1.3-3 CurrentTask</a></span>
<span class=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
spanclass=ContSS">br/< class=nocss"&bsp;&bsp;/>ahref=chap1.tml#X7A023A657BB4F17D">1.3-5 TaskStarted</a></span>
<span class="ContSSjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<<spanclass=GAPpromptgapgt<span>span ="RunAsyncTask((unction( (Hello,!n"; );;/>
</div></div>
<div< ="GAPpromptggt;span><pan class""!ist<span>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="--Thread 0 [0]
s =ContSS><br >span =nocss"&&<span>a =chap1.tml#X8431B91487A8A3F1">1.4-2 TaskCancellationRequested</a></span>
<span <class=GAPprompt>gap&t;/><span class=GAPinput>5span>
<span -- Switchingthread
</div></div[]Hello,worldjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
g&;
</span>
</div>
<div class="ContSect"><span class="tocline">pre>/div>
/span>
<divjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<span ="ContSS>br/< class=nocss"&;nbsp;/>< ".#X80CB3247854A46E4">1.6-1 NewMilestone</a></span>
<span class=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
< /< =nocss"nbsp;nbsp;/span>a "h#X7ACB26D38096CD56">1.6-3 AchieveMilestone</a></span>
<span java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div</divjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
<vjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
<h3
<<h5.- <h5>
<h4>1.1java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<>code class""RunTask<> prepares task forexecutionand it. thefunction var class"rg"func/ arguments var =Arg>rg1/> < classA"argn<var>(f .The <ar ""func/ the ofthe .The<class"unc><code itselfreturns atask can be used by functions thatexpectatask argument./>
<>aid=X7A86AE967D2A9E94"=X7A86AE967D2A9E94>/>p
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
span "">ap&;/ < class""WaitTask(ask;/span>
<span <p><code classfunc>/>prepares a taskfor,but unlike< class=func"java.lang.StringIndexOutOfBoundsException: Range [112, 111) out of bounds for length 484
[ 1, 2, 3 ]
</pre></div>
<p><code class="func">RunTask</code> (<a href="chap1.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p><code classs =GAPprompt>apg;/ < class""t2 : (x->x*x,4;<spanjava.lang.StringIndexOutOfBoundsException: Index 98 out of bounds for length 98
<div class="example"><pre>
<span java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
s ""gap&;</pan s class=GAPinput"task2 :RunTask(roduct,[5001.10000];<span>
<span class="GAPprompt
true
<><div>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
span="APprompt>&;/span><pan ="GAPinput>: (roduct,[.5000];<span>
<span class="GAPprompt">gap></span> <span class="GAPinput">task2 := DelayTask(Product, [5001..10000]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">WaitTask(task1, task2);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">TaskResult(task1) * TaskResult(task2) = Factorial(10000);</span>
true
</pre></div>
<p>Note that <code class="func">WaitTask</code> (<a href="chap1.html#X861BC1488345C424"><span class="RefLink">1.2-9</span></a>) is used here to start execution of both tasks; otherwise, <code class="code">task2</code> would not be started until <code class="code">TaskResult(task1)</code> has been evaluated.</p>
<p>To start execution of a delayed task, you can also use <code class="code">ExecuteTask</code>. This has no effect if a task has already been running.</p>
<p>For convenience, you can also use <code class="func">ImmediateTask</code> (<a href="chap1.html#X84AFD0FA7A4E3633"><span class="RefLink">1.2-7</span></a>) to execute a task synchronously (i.e., the task is started immediately and the call does not return until the task has completed).</p>
<p>This is indistinguishable from calling the function directly, but provides the same interface as normal tasks.</p>
<p>If e.g. you want to call a function only for its side-effects, it can be useful to ignore the result of a task. <code class="func">RunAsyncTask</code> (<a href="chap1.html#X856288C27C62B14A"><span class="RefLink">1.2-4</span></a>) provides the necessary functionality. Such a task cannot be waited for and its result (if any) is ignored.</p>
<p>For more information on the multi-threaded user interface, see Chapter <a href="chap4.html#X7AFF436381C319CD"><span class="RefLink">4</span></a>.</p>
<p>Task arguments are generally copied so that both the task that created them and the task that uses them can access the data concurrently without fear of race conditions. To avoid copying, arguments should be made shared or public (see the relevant parts of section <a href="chap3.html#X87315FA584A37637"><span class="RefLink">3.6</span></a> on migrating objects between regions); shared and public arguments will not be copied.</p>
<p>HPC-GAP currently has multiple implementations of the task API. To use an alternative implementation to the one<p<code class="func"OnTaskCancellationReturn</code> is a convenience function that does the same as: <code class="code">OnTaskCancellation(function() return value; end);</code></p>
<div class=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p><code class="func">RunTask</code<4>1.5 span class="eading>Conditions<span</h4>
<div class="example"><pre>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<span=">gap&;<span>< class=GAPinput"t2: (-g;*, 4);<span>
<span class="GAPprompt">gap></span> <span class="GAPinput">t := ScheduleTask([t1, t2], function()</span>
<span<> area way to representabstract to cancontribute<p
<span class="java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
< class=GAPprompt>><span><pan class="APinput>TaskResult(t)<span> 25
</pre></div>
<div class="func"><table class="func" width="<>The code="unc"NewMilestone/ode>function creates newmilestone.Its is a ,which bea ofintegersand/strings omitted the defaults to c class=code"[]/./>
p< class="func"DelayTask<code as <ode class=func>< < href".#X7DEC1649841E3813"< class""121/>> startis untilitis waited for includingimplicitly bycalling < =func><code>(a="chap1.html#X7A86C732823E04B6"><span class="RefLink">1.2-11</span></a>)).</p>
<p>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<h5>1.2-4 java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; MakeTaskAsync</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">MakeTaskAsync</code> turns a synchronous task into an asynchronous task that cannot be waited for and whose result will be ignored.</p>
<div class="func"><table class="func" width="100%"><tr><td class=<h5>.6-3AchieveMilestone</h5>
<p><code class="func">ImmediateTask</code> executes the task specified by its arguments synchronously, usually within the current
<p><a id=<>The codeclass=func><code allows program to achieve a milestone in a single step without adding individual targets to it. This is most useful in conjunction with the default value for <code class="func">NewMilestone</code> (<a href="chap1.html#X80CB3247854A46E4"><span class="RefLink">1.6-1</span></a>), e.g.</p>
<h5>1.2-8 ExecuteTask</h5>
<div class="func"><<span class="GAPprompt">gap></span> <span class="GAPinput">m := NewMilestone();;</span>
p>codeclass"func">ExecuteTask<code> <varclass"">ask</ar alreadyrunning.It hasonly effect itsargument atask returned by code ="func">elayTask/ <=chap1html#X85BC2BBC7EF5B22E"><span class="RefLink">1.2-3</span></a>); otherwise, it is a no-op.</p>
<h5>1.2-9 java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 12
<div class="func"><table class="func" width="100%"><tr><td classjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
< class=func ="width=100"<>t class="><ode class=func"&8227; WaitTask</code>( <var class="Arg">condition</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p><code class="java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p><a id="<p><code classfunc><code>testsexplicitly has .It c =keyw"true<code>on success,c =keyw><code>otherwise<p>
<div class="func"><div =e"<>
<> <code class="WaitAnyTask/code>function for any of argumentsto ,then the number that ./>
<div class="example"><pre>
class=GAPprompt"&;<span>< class=GAPinput"task1 : DelayTaskx&;(x) 321);/java.lang.StringIndexOutOfBoundsException: Index 119 out of bounds for length 119
="GAPinput"> :=DelayTaskx&t;SortedList(),[,,];<span>
<span class="GAPprompt">gap></span> <span class="GAPinput"java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 2
<span class="GAPprompt">gap<span class=GAPprompt>&t<span>span class=GAPinput"IsMilestoneAchieved()<span>
<span class="java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 4
<span class="GAPprompt">></span> <span class="GAPinput"> else</span>
<span class="GAPprompt">></span> <span class="GAPinput"> Display(TaskResult(task2));Display(TaskResult(task1));</span>
<span class="GAPprompt">></span> <span class="GAPinput"> fi;</span>
[ 4, 5, 6 ]
[ 1, 2, 3 ]
</pre></div>
<p>One can pass a list of tasks to <code class="code">WaitAnyTask</code> as an argument; <code class="code">WaitAnyTask([task1, ..., taskn])</code> behaves identically to <code class="code">WaitAnyTask(task1, ..., taskn)</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; TaskResult</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The <code class="func">TaskResult</code> function returns the result of a task. It implicitly calls <code class="func">WaitTask</code> (<a href="chap1.html#X861BC1488345C424"><span class="RefLink">1.2-9</span></a>) if that is necessary. Multiple invocations of <code class="func">TaskResult</code> with the same task argument will not do repeated waits and always return the same value.</p>
<p>If the function executed by <var class="Arg">task</var> encounters an error, <code class="func">TaskResult</code> returns <code class="keyw">fail</code>. Whether <var class="Arg">task</var> encountered an error can be checked via <code class="func">TaskSuccess</code> (<a href="chap1.html#X87BB5EF38415B923"><span class="RefLink">1.3-1</span></a>). In case of an error, the error message can be retrieved via <code class="func">TaskError</code> (<a href="chap1.html#X85F42F5E7E04F3C2"><span class="RefLink">1.3-2</span></a>).</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; TaskSuccess</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">TaskSuccess</code> waits for <var class="Arg">task</var> and returns <code class="keyw">true</code> if the it finished without encountering an error. Otherwise the function returns <code class="keyw">false</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; TaskError</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">TaskError</code> waits for <var class="Arg">task</var> and returns its error message, if it encountered an error. If it did not encounter an error, the function returns <code class="keyw">fail</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; RunningTasks</code>( )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function returns the number of currently running tasks. Note that it is only an approximation and can change as new tasks are being started by other threads.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; TaskStarted</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function returns true if the task has started executing (i.e., for any non-delayed task), false otherwise.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; TaskFinished</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function returns true if the task has finished executing and its result is available, false otherwise.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; TaskIsAsync</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function returns true if the task is asynchronous, true otherwise.</p>
<p>HPC-GAP uses a cooperative model for task cancellation. A programmer can request the cancellation of another task, but it is up to that other task to actually terminate itself. The tasks library has functions to request cancellation, to test for the cancellation state of a task, and to perform actions in response to cancellation requests.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; CancelTask</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">CancelTask</code> submits a request that <var class="Arg">task</var> is to be cancelled.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; OnTaskCancellation</code>( <var class="Arg">exit_func</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">OnTaskCancellation</code> tests if cancellation for the current task has been requested. If so, then <var class="Arg">exit_func</var> will be called (as a parameterless function) and the current task will be aborted. The result of the current task will be the value of <var class="Arg">exit_func()</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; OnTaskCancellationReturn</code>( <var class="Arg">value</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">OnTaskCancellationReturn</code> is a convenience function that does the same as: <code class="code">OnTaskCancellation(function() return value; end);</code></p>
<p><code class="func">ScheduleTask</code> (<a href="chap1.html#X7A86AE967D2A9E94"><span class="RefLink">1.2-2</span></a>) and <code class="func">WaitTask</code> (<a href="chap1.html#X861BC1488345C424"><span class="RefLink">1.2-9</span></a>) can be made to wait on more complex conditions than just tasks. A condition is either a milestone, a task, or a list of milestones and tasks. <code class="func">ScheduleTask</code> (<a href="chap1.html#X7A86AE967D2A9E94"><span class="RefLink">1.2-2</span></a>) starts its task and <code class="func">WaitTask</code> (<a href="chap1.html#X861BC1488345C424"><span class="RefLink">1.2-9</span></a>) returns when the condition has been met. A condition represented by a task is met when the task has completed. A condition represented by a milestone is met when the milestone has been achieved (see below). A condition represented by a list is met when all conditions in the list have been met.</p>
<<=func"<able class""%>tr< "tdleft"< class""&8227;CancelTask<code> <arclass=Arg"task<var>)/d<td ="dright">( function )</td></tr></table></div>
<>a id""name=X80CB3247854A46E4>/>/>
<5>.- NewMilestone/>
<<h5>14- TaskCancellationRequested/java.lang.StringIndexOutOfBoundsException: Range [39, 41) out of bounds for length 40
p>The< class""NewMilestone<code java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 231
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; ContributeToMilestone</code>( <var class="Arg">milestone</var>, <var class="Arg">target</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The <java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<p><a idjava.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
<h5>1.6-3 AchieveMilestone</h5>
<div class="APprompt>&;/>< class=GAPinput"task=RunTask(function)/spanjava.lang.StringIndexOutOfBoundsException: Range [95, 96) out of bounds for length 95
pThe<code class=func>AchieveMilestone<>function aprogram oachieve a inas without ndividual targetsto.This s useful in onjunction the default value for <code class="func">NewMilestone</code> (<a href="chap1.html#X80CB3247854A46E4"><span class="RefLink">1.6-1</span></a>), e.g.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; IsMilestoneAchieved</code>( <var class="Arg">milestone</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">IsMilestoneAchieved</code> tests explicitly if a milestone has been achieved. It returns <code class="keyw">true</code> on success, <code class="keyw">false</code> otherwise.</p>
<hr />
<p class="foot">generated by <a href=https//ww.rwth-achen./Frank.GAPDoc"GAPDoc2HTML<a<pjava.lang.StringIndexOutOfBoundsException: Index 112 out of bounds for length 112
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
</html>
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.282Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.