Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/factint/tables/brent/   (GAP Algebra Version 4.15.1©)  Datei vom 15.10.2019 mit Größe 1 kB image not shown  

Impressum chap1.html   Interaktion und
PortierbarkeitHTML

 

 products/Sources/formale Sprachen/GAP/doc/hpc/chap1.html


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GAP (hpc) - Chapter 1: Tasks</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap1"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chapInd.html">Ind</a>  </div>

<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"<panclass="&;/><span =GAPinput"           TaskResult(1) +(2;/>
span =GAPprompt"gapg;</span><class""task : RunTask(-gt;SortedList() [,21]);/span>
<span<panclass="gap;</ <span ""TaskResult(t)<span>
[ 1, 2, 3 ]
</pre></div>

<p><pre>/div>


<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">task := ImmediateTask(x -> SortedList(x), [3,2,1]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">TaskResult(task);</span>
[ 1, 2, 3 ]
</pre></div>

<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">RunAsyncTask(function() Print("Hello, world!\n"); end);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">!list</span>
--- Thread 0 [0]
--- Thread 5 [5] (pending output)
<span class="GAPprompt">gap></span> <span class="GAPinput">!5</span>
--- Switching to thread 5
[5] Hello, world!
!0
--- Switching to thread 0
gap>
</pre></div>

<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>

<p><a id="X7C9F2EF384645B8F" name="X7C9F2EF384645B8F"></a></p>

<h4>1.2 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p><a id="X7DEC1649841E3813" name="X7DEC1649841E3813"></a></p>

<h5>1.2-1 RunTask</h5>

<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>

<p><a id="X7A86AE967D2A9E94" name="X7A86AE967D2A9E94"></a></p>

<h5>1.2-2 ScheduleTask</h5>

<div class=
<p><code<>< id="X7EE6DC40842CD74B" name="X7EE6DC40842CD74B"></a></p>


<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>

<h5>161NewMilestone/>

<p><a id="X85BC2BBC7EF5B22E" name="X85BC2BBC7EF5B22E"></a></p>

<h5>1.2-3 DelayTask</h5>

<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; RunAsyncTask</code>( <var class="Arg">func</var>[, <var class="Arg">arg1</var>, <var class="Arg">...</var>, <var class="Arg">argn</var>] )</td><td class="tdright">( function )</td></tr></table></div>
p<odeclass"unc"RunAsyncTask</code>createsan  task   like<class"">unTask/>(<href=chap1.tml

<p><a id="X7EAC7A4B86F5F74C" name="X7EAC7A4B86F5F74C"></a></p>

<h5>1.2-5 ScheduleAsyncTask</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; ScheduleAsyncTask</code>( <var class="Arg">condition</var>, <var class="Arg">func</var>[, <var class="Arg">arg1</var>, <var class="Arg">...</var>, <var class="Arg">argn</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<p><a id="X791CA0E07B16E7F9" name="X791CA0E07B16E7F9"></a></p>

<h5>1.2-6 MakeTaskAsync</h5>

<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>

<p><a id="X84AFD0FA7A4E3633" name="X84AFD0FA7A4E3633"></a></p>

<h5>1.2-7 ImmediateTask</h5>

<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>

<p><a id="X861BC1488345C424" name="X861BC1488345C424"></a></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>

<p><a id="X7A86C732823E04B6" name="X7A86C732823E04B6"></a></p>

<h5>1.2-11 TaskResult</h5>

<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>

<p><a id="X830A82A7847993FF" name="X830A82A7847993FF"></a></p>

<h5>1.2-12 CullIdleTasks</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; CullIdleTasks</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function terminates unused worker threads.</p>

<p><a id="X86F8419B7968345B" name="X86F8419B7968345B"></a></p>

<h4>1.3 <span class="Heading">Information about tasks</span></h4>

<p><a id="X87BB5EF38415B923" name="X87BB5EF38415B923"></a></p>

<h5>1.3-1 TaskSuccess</h5>

<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>

<p><a id="X85F42F5E7E04F3C2" name="X85F42F5E7E04F3C2"></a></p>

<h5>1.3-2 TaskError</h5>

<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>

<p><a id="X7C0C66E37DB9ACC0" name="X7C0C66E37DB9ACC0"></a></p>

<h5>1.3-3 CurrentTask</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; CurrentTask</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<p>The <code class="func">CurrentTask</code> returns the currently running task.</p>

<p><a id="X7DA4E06B792002C7" name="X7DA4E06B792002C7"></a></p>

<h5>1.3-4 RunningTasks</h5>

<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>

<p><a id="X7A023A657BB4F17D" name="X7A023A657BB4F17D"></a></p>

<h5>1.3-5 TaskStarted</h5>

<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>

<p><a id="X7E7500E17EC1067D" name="X7E7500E17EC1067D"></a></p>

<h5>1.3-6 TaskFinished</h5>

<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>

<p><a id="X7B37CED386024A1F" name="X7B37CED386024A1F"></a></p>

<h5>1.3-7 TaskIsAsync</h5>

<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><a id="X7B286945821A3BBA" name="X7B286945821A3BBA"></a><<table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; TaskIsAsync</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>

<h4>1.4 <span class="Heading">Cancelling tasks</span></h4>

<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>

<p><a id="X86C26E3081C3C9AA" name="X86C26E3081C3C9AA"></a></p>

<h5>1.4-1 CancelTask</h5>

<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>

<p><a id="X8431B91487A8A3F1" name="X8431B91487A8A3F1"></a></p>

<h5>1.4-2 TaskCancellationRequested</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&an style='color:green'>#8227; TaskCancellationRequested</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">TaskCancellationRequested</code> returns true if <code class="func">CancelTask</code> (<a href="chap1.html#X86C26E3081C3C9AA"><span class="RefLink">1.4-1</span></a>) has been called for <var class="Arg">task</var>, false otherwise.</p>

<p><a id="X7D61F9C487232DE7" name="X7D61F9C487232DE7"></a></p>

<h5>1.4-3 OnTaskCancellation</h5>

<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="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">task := RunTask(function()</span>
<span class="GAPprompt">></span> <span class="GAPinput">     while true do</span>
<span class="GAPprompt">></span> <span class="GAPinput">       OnTaskCancellation(function() return 314; end);</span>
<span class="GAPprompt">></span> <span class="GAPinput">     od;</span>
<span class="GAPprompt">></span> <span class="GAPinput">   end);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">CancelTask(task);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">TaskResult(task);</span>
314
</pre></div>

<p><a id="X82D1773F8058CA54" name="X82D1773F8058CA54"></a></p>

<h5>1.4-4 OnTaskCancellationReturn</h5>

<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><a id="X802FC4C284F68696" name="X802FC4C284F68696"></a></p>

<h4>1.5 <span class="Heading">Conditions</span></h4>

<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>

<>.- />

<h4>1.6 <span class="Heading">Milestones</span></h4>

<<=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

<p><a id="X800AE2737CB715C5" name="X800AE2737CB715C5"></a></p>

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="example"><pre>
<span class="GAPprompt">gap><</>span class">);/
<span class="GAPprompt">gap></span> <span class="GAPinput">AchieveMilestone(m);</span>
</pre></div>

<p>></p>

<p><a id="X83E7AF007E040FB9" name="X83E7AF007E040FB9"></a></p>

<h5>1.6-4 IsMilestoneAchieved</h5>

<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">m := NewMilestone([1,2]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ContributeToMilestone(m, 1);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMilestoneAchieved(m);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">ContributeToMilestone(m, 2);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMilestoneAchieved(m);</span>
true
</pre></div>


<div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap0.html">[Previous Chapter]</a>    <a href="chap2.html">[Next Chapter]</a>   </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a <span class"GAPprompt">gap></span> <span class="GAPinput">CancelTask(task);</span>

<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
C=97 H=73 G=85

¤ 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:  ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.