Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/ferret/YAPB /simple_graph/   (GAP Algebra Version 4.15.1©)  Datei vom mit Größe 0 B image not shown  

Quelle  chap1_mj.html   Sprache: HTML

 

 products/Sources/formale Sprachen/GAP/doc/hpc/chap1_mj.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>
<script type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<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_mj.html">Top</a>  <a href="chap1_mj.html">1</a>  <a href="chap2_mj.html">2</a>  <a href="chap3_mj.html">3</a>  <a href="chap4_mj.html">4</a>  <a href="chap5_mj.html">5</a>  <a href="chap6_mj.html">6</a>  <a href="chap7_mj.html">7</a>  <a href="chap8_mj.html">8</a>  <a href="chap9_mj.html">9</a>  <a href="chap10_mj.html">10</a>  <a href="chap11_mj.html">11</a>  <a href="chapInd_mj.html">Ind</a>  </div>

<div class="chlinkprevnexttop"> <a href="chap0_mj.html">[Top of Book]</a>   <a href="chap0_mj.html#contents">[Contents]</a>    <a href="chap0_mj.html">[Previous Chapter]</a>    <a href="chap2_mj.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap1.html">[MathJax off]</a></p>
<p><a id="X7EA285468533E153" name="X7EA285468533E153"></a></p>
<div class="ChapSects"><a href="chap1_mj.html#X7EA285468533E153">1 <span class="Heading">Tasks</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap1_mj.html#X8389AD927B74BA4A">1.1 <span class="Heading">Overview</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap1_mj.html#X7C9F2EF384645B8F">1.2 <span class="Heading">Running tasks</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7DEC1649841E3813">1.2-1 RunTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7A86AE967D2A9E94">1.2-2 ScheduleTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X85BC2BBC7EF5B22E">1.2-3 DelayTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X856288C27C62B14A">1.2-4 RunAsyncTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7EAC7A4B86F5F74C">1.2-5 ScheduleAsyncTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X791CA0E07B16E7F9">1.2-6 MakeTaskAsync</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X84AFD0FA7A4E3633">1.2-7 ImmediateTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X83D2E32C8759FB37">1.2-8 ExecuteTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X861BC1488345C424">1.2-9 WaitTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X81489CD684EA11B6">1.2-10 WaitAnyTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7A86C732823E04B6">1.2-11 TaskResult</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X830A82A7847993FF">1.2-12 CullIdleTasks</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap1_mj.html#X86F8419B7968345B">1.3 <span class="Heading">Information about tasks</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X87BB5EF38415B923">1.3-1 TaskSuccess</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X85F42F5E7E04F3C2">1.3-2 TaskError</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7C0C66E37DB9ACC0">1.3-3 CurrentTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7DA4E06B792002C7">1.3-4 RunningTasks</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7A023A657BB4F17D">1.3-5 TaskStarted</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7E7500E17EC1067D">1.3-6 TaskFinished</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7B37CED386024A1F">1.3-7 TaskIsAsync</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap1_mj.html#X7B286945821A3BBA">1.4 <span class="Heading">Cancelling tasks</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X86C26E3081C3C9AA">1.4-1 CancelTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X8431B91487A8A3F1">1.4-2 TaskCancellationRequested</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7D61F9C487232DE7">1.4-3 OnTaskCancellation</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X82D1773F8058CA54">1.4-4 OnTaskCancellationReturn</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap1_mj.html#X802FC4C284F68696">1.5 <span class="Heading">Conditions</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap1_mj.html#X7EE6DC40842CD74B">1.6 <span class="Heading">Milestones</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X80CB3247854A46E4">1.6-1 NewMilestone</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X800AE2737CB715C5">1.6-2 ContributeToMilestone</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X7ACB26D38096CD56">1.6-3 AchieveMilestone</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap1_mj.html#X83E7AF007E040FB9">1.6-4 IsMilestoneAchieved</a></span>
</div></div>
</div>

<h3>1 <span class="Heading">Tasks</span></h3>

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

<h4>1.1 <span class="Heading">Overview</span></h4>

<p>Tasks provide mid- to high-level functionality for programmers to describe asynchronous workflows. A task is an asynchronously or synchronously executing job; functions exist to create tasks that are executed concurrently, on demand, or in the current thread; to wait for their completion, check their status, and retrieve any results.</p>

<p>Here is a simple example of sorting a list in the background:</p>


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

<p><code class="func">RunTask</code> (<a href="chap1_mj.html#X7DEC1649841E3813"><span class="RefLink">1.2-1</span></a>) dispatches a task to run in the background; a task is described by a function and zero or more arguments that are passed to <code class="func">RunTask</code> (<a href="chap1_mj.html#X7DEC1649841E3813"><span class="RefLink">1.2-1</span></a>). <code class="func">WaitTask</code> (<a href="chap1_mj.html#X861BC1488345C424"><span class="RefLink">1.2-9</span></a>) waits for the task to complete; and <code class="code">TaskResult</code> returns the result of the task.</p>

<p><code class="func">TaskResult</code> (<a href="chap1_mj.html#X7A86C732823E04B6"><span class="RefLink">1.2-11</span></a>) does an implicit <code class="func">WaitTask</code> (<a href="chap1_mj.html#X861BC1488345C424"><span class="RefLink">1.2-9</span></a>), so the second line above can actually be omitted:</p>


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

<p>It is simple to run two tasks in parallel. Let's compute the factorial of 10000 by splitting the work between two tasks:</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">task1 := RunTask(Product, [1..5000]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">task2 := RunTask(Product, [5001..10000]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">TaskResult(task1) * TaskResult(task2) = Factorial(10000);</span>
true
</pre></div>

<p>You can use <code class="func">DelayTask</code> (<a href="chap1_mj.html#X85BC2BBC7EF5B22E"><span class="RefLink">1.2-3</span></a>) to delay executing the task until its result is actually needed.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">task1 := DelayTask(Product, [1..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_mj.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_mj.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_mj.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_mj.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_mj.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 documented here, set the environment variable <code class="code">GAP_WORKSTEALING</code> to a non-empty value before starting GAP.</p>

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

<h4>1.2 <span class="Heading">Running tasks</span></h4>

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

<h5>1.2-1 RunTask</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; RunTask</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><code class="func">RunTask</code> prepares a task for execution and starts it. The task will call the function <var class="Arg">func</var> with arguments <var class="Arg">arg1</var> through <var class="Arg">argn</var> (if provided). The return value of <var class="Arg">func</var> is the result of the task. The <code class="func">RunTask</code> call itself returns a task object that can be used by functions that expect a task argument.</p>

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

<h5>1.2-2 ScheduleTask</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ScheduleTask</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><code class="func">ScheduleTask</code> prepares a task for execution, but, unlike <code class="func">RunTask</code> (<a href="chap1_mj.html#X7DEC1649841E3813"><span class="RefLink">1.2-1</span></a>) does not start it until <var class="Arg">condition</var> is met. See on how to construct conditions. Simple examples of conditions are individual tasks, where execution occurs after the task completes, or lists of tasks, where execution occurs after all tasks in the list complete.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">t1 := RunTask(x->x*x, 3);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">t2 := RunTask(x->x*x, 4);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">t := ScheduleTask([t1, t2], function()</span>
<span class="GAPprompt">></span> <span class="GAPinput">          return TaskResult(t1) + TaskResult(t2);</span>
<span class="GAPprompt">></span> <span class="GAPinput">   end);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">TaskResult(t);</span>
25
</pre></div>

<p>While the above example could also be achieved with <code class="func">RunTask</code> (<a href="chap1_mj.html#X7DEC1649841E3813"><span class="RefLink">1.2-1</span></a>) in lieu of <code class="func">ScheduleTask</code>, since <code class="func">TaskResult</code> (<a href="chap1_mj.html#X7A86C732823E04B6"><span class="RefLink">1.2-11</span></a>) would wait for <var class="Arg">t1</var> and <var class="Arg">t2</var> to complete, the above implementation does not actually start the final task until the others are complete, making it more efficient, since no additional worker thread needs to be occupied.</p>

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

<h5>1.2-3 DelayTask</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; DelayTask</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><code class="func">DelayTask</code> works as <code class="func">RunTask</code> (<a href="chap1_mj.html#X7DEC1649841E3813"><span class="RefLink">1.2-1</span></a>), but its start is delayed until it is being waited for (including implicitly by calling <code class="func">TaskResult</code> (<a href="chap1_mj.html#X7A86C732823E04B6"><span class="RefLink">1.2-11</span></a>)).</p>

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

<h5>1.2-4 RunAsyncTask</h5>

<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><code class="func">RunAsyncTask</code> creates an asynchronous task. It works like <code class="func">RunTask</code> (<a href="chap1_mj.html#X7DEC1649841E3813"><span class="RefLink">1.2-1</span></a>), except that its result will be ignored.</p>

<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><code class="func">ScheduleAsyncTask</code> creates an asynchronous task. It works like <code class="func">ScheduleTask</code> (<a href="chap1_mj.html#X7A86AE967D2A9E94"><span class="RefLink">1.2-2</span></a>), except that its result will be ignored.</p>

<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="tdleft"><code class="func">&#an style='color: green'>8227; ImmediateTask</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><code class="func">ImmediateTask</code> executes the task specified by its arguments synchronously, usually within the current thread.</p>

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

<h5>1.2-8 ExecuteTask</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; ExecuteTask</code>( <var class="Arg">task</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">ExecuteTask</code> starts <var class="Arg">task</var> if it is not already running. It has only an effect if its argument is a task returned by <code class="func">DelayTask</code> (<a href="chap1_mj.html#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 WaitTask</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; WaitTask</code>( <var class="Arg">task1</var>, <var class="Arg">...</var>, <var class="Arg">taskn</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; WaitTask</code>( <var class="Arg">condition</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; WaitTasks</code>( <var class="Arg">task1</var>, <var class="Arg">...</var>, <var class="Arg">taskn</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">WaitTask</code> waits until <var class="Arg">task1</var> through <var class="Arg">taskn</var> have completed; after that, it returns. Alternatively, a condition can be passed to <code class="func">WaitTask</code> in order to wait until a condition is met. See on how to construct conditions. <code class="func">WaitTasks</code> is an alias for <code class="func">WaitTask</code>.</p>

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

<h5>1.2-10 WaitAnyTask</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; WaitAnyTask</code>( <var class="Arg">task1</var>, <var class="Arg">...</var>, <var class="Arg">taskn</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The <code class="func">WaitAnyTask</code> function waits for any of its arguments to finish, then returns the number of that task.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">task1 := DelayTask(x->SortedList(x), [3,2,1]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">task2 := DelayTask(x->SortedList(x), [6,5,4]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">which := WaitAnyTask(task1, task2);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">if which = 1 then</span>
<span class="GAPprompt">></span> <span class="GAPinput">     Display(TaskResult(task1));Display(TaskResult(task2));</span>
<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_mj.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_mj.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_mj.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>

<"java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 221
 "java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 239

<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>
<code =func"TaskError<code> for <class=Arg"task</> returns 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="X7C0C66E37DB9ACC0span ""< /<pan class=nocss"&bsp;nbsp;<span>< =c.html#X7B37CED386024A1F>137TaskIsAsync/a><span>

<h5>1.3-3 CurrentTask</h5>

<div class="pan "ContSS"<br><pan =">nbsp&;<s>a href=chap1_mj.#X8431B91487A8A3F11.4-2TaskCancellationRequesteda>/pan>
p><code class"">urrentTask/>returns java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 84

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

s class""< >s class=">nbsp;;<span>a href=".#80B3247854A46E4>.61 /a><>

<div class="func"><table class="func" width="100%"><tr><td span ""b >span class=nocss"&bsp;;<span> href="chap1_mjh#7CB26D38096CD56"1.6-3 </>/pan>
<>java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 169

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

<h5>1.3-5 TaskStarted</h5>

<="func =100">tr< =t">""&#8227;TaskStarted<code> <var ="">ask<var>)/td< class=tdright>(;&bsp;<>/><>/div
<p

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

<h5>1.3-6 TaskFinished</h5>

<div class="func"><table class="func" width="100%"><tr><span class="">gapg;/spanspan class="GAPinput">WaitTask(task);</span>
<This   trueif  task  executing its resultjava.lang.StringIndexOutOfBoundsException: Range [100, 82) out of bounds for length 114

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

<h5>1.3-7 TaskIsAsync</h5>

iv ="func"<able class=func"width=100%<r<tdclass"">code ="">#8227;TaskIsAsync<code> var ="Arg"><var>)<td> class="(nbsp;&;<td>/>/table>/>
<> function   the   ,true ./>

<p><a id="X7B286945821A3BBA" name="X7B286945821A3BBA"></java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 0

<h4>1.4 <span class="Heading">Cancelling tasks</span></h4><span class="GAPprompt">gap></span> <span class="GAPinput">TaskResult(task);</span>

<p>HPC-GAP </pre><>

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

<h5>1.4-1 CancelTask<s =GAPprompt"gap&t;<s><java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 111

<div class="func"><table class="funcjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 4
<</var> is to be cancelled<p>

<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

<h5></h5>

<div class="func"><table class="func" width="100%"><tr><<span class"">gap&;</span>span=GAPinput"T()*TaskResult()  Factorial(0000)<span>
<>code ""TaskCancellationRequestedcode>  true  <ode "func"><ode>(a href="chap1_mjhtmlXC26">span "RefLink">.-</pan>/a>) has  called  < class"rg"task<var>  otherwise./>

<p><a id="X7D61F9C487232DE7" name="X7D61F9C487232DE7"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<h5>1.4-3 OnTaskCancellation</h5>

<div%"><tr<td =tdleft>code class="func"&#227;OnTaskCancellation</code( <var class=Arg">exit_func/var>)<td>td class"">&;java.lang.StringIndexOutOfBoundsException: Range [203, 202) out of bounds for length 233
<>< class=func"OnTaskCancellation/code>tests cancellation for the current task has been requested. If so, then <var class="Arg">exit_func</var> will be called (as class="APprompt"g;<span><pan "GAPinput"task =ImmediateTaskx-gt;() [,1);/pan>


<divjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<span class="GAPprompt">gap></span> <span class="
<java.lang.StringIndexOutOfBoundsException: Range [57, 5) out of bounds for length 84
<
< ="&;/span>< class=GAPinput">     java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 74
<span class="GAPprompt">></span> <span class="GAPinput">   end);;</span>
<panclass=GAPprompt>>/pan> sclass="CancelTask(;<span>
<span class="GAPprompt">gap></span> <span java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 33
314
</<div>

<d"82D1773F8058CA54 name=X82D1773F8058CA54"</><>

<java.lang.StringIndexOutOfBoundsException: Range [34, 3) out of bounds for length 39

<div p>HPC-GAPcurrently has  implementations of the task API. To use an alternative implementation to the one documented here, set the environment variable <code java.lang.StringIndexOutOfBoundsException: Index 170 out of bounds for length 0
<p><code class="java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0

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

<h4>1.5 <span class="Heading"><p><code class="func">RunTask</codea for executionand starts it.The taskwill  the < =Arg/  < "Arg><var>through var =A"argn</ar>(if java.lang.StringIndexOutOfBoundsException: Range [234, 233) out of bounds for length 445

<p><code class="func">ScheduleTask</code> (<a href="chap1_mj.html#X7A86AE967D2A9E94"><span class="RefLink">1.2-2</span></a>) 

<>a "X7EE6DC40842CD74B"name=X7EE6DC40842CD74B><a<p>

<4>. span ="eading"Milestones</pan>/>

<p>Milestonesdiv =example>pre>

<p><a id="<span class="GAPprompt">gap;/>< class=GAPinput"t2 = (&x*,4);<>

<h5>1.6-1 NewMilestone</h5>

<div class="funcppan =GAPprompt"gap>s><span class="GAPinput"();/>
<p>The <code class="func">NewMilestone</code> function creates a new milestone. Its argument is a list of targets, which must be a list of integers and/or strings. If omitted, the list defaults to <code class="code">[0]</code>.</p>

<p><a id="X800AE2737CB715C5" name="X800AE2737CB715C5"></a>java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

<h5>1.6-2 ContributeToMilestone</h5>

<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 <code class="func">ContributeToMilestone</code> milestone function contributes the specified target to the milestone. Once all targets have been contributed to a milestone, it has been achieved.</p>

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

<h5>1.6-3 AchieveMilestone</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; AchieveMilestone</code>( <var class="Arg">milestone</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The <code class="func">AchieveMilestone</code> function allows a 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_mj.html#X80CB3247854A46E4"><span class="RefLink">1.6-1</span></a>), e.g.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">m := NewMilestone();;</span>
<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_mj.html">[Top of Book]</a>   <a href="chap0_mj.html#contents">[Contents]</a>    <a href="chap0_mj.html">[Previous Chapter]</a>    <a href="chap2_mj.html">[Next Chapter]</a>   </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0_mj.html">Top</a>  <a href="chap1_mj.html">1</a>  <a href="chap2_mj.html">2</a>  <a href="chap3_mj.html">3</a>  <a href="chap4_mj.html">4</a>  <a href="chap5_mj.html">5</a>  <a href="chap6_mj.html">6</a>  <a href="chap7_mj.html">7</a>  <a href="chap8_mj.html">8</a>  <a href="chap9_mj.html">9</a>  <a href="chap10_mj.html">10</a>  <a href="chap11_mj.html">11</a>  <a href="chapInd_mj.html">Ind</a>  </div>

<hr />
<p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>

Messung V0.5 in Prozent
C=98 H=69 G=84

¤ Dauer der Verarbeitung: 0.285 Sekunden  ¤

*© Formatika GbR, Deutschland






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.