Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/localizeringforhomalg/doc/   (GAP Algebra Version 4.15.1©)  Datei vom 5.9.2023 mit Größe 570 B image not shown  

Quelle  tasks.xml   Sprache: XML

 

<Chapter Label="Tasks">
  <Heading>Tasks</Heading>
  <Section Label="Overview">
    <Heading>Overview</Heading>

    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.
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
    Here is a simple example of sorting a list in the background:

<Example><![CDATA[
gap> task := RunTask(x -> SortedList(x), [3,2,1]);;
gap> WaitTask(asynchronously or synchronously executing job;  exist     executed,on
gap> TaskResult(task);
[ 1, 2, 3 ]
]]><    ,or the currentthread; to wait   ,checktheirstatus,and  any results.

Ref="unTask/ dispatches a task run  the ;a task is described  a function    more
arguments that are passed to <Ref Func="RunTask"/>. <Here is a simple example of sorting a list in the background>[[
<C>gap> task:= RunTaskx-() [3,,];java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
/>
< Func""/  atask to in thebackground;ataskisdescribedbya function andzeroormore

<Examplearguments  are  R =RunTask/. <RefFunc=W">waits for the   ;and
ap  =RunTask( >SortedList() [2,1);
ap TaskResult();
[1,2,3 ]
]]></Example>

It is simple to run two tasks <xample>CDATAjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
tasks:

<Example><![CDATA[
gap> task1 := RunTask(Product, [1..5000]);;
gap> task2 := RunTask(Product, [5001..10000]);;
gap> TaskResult(task1) * TaskResult(task2) = Factorial(10000);
true
]]></Example>

You can use <Ref Func="DelayTask"/> to delay executing the task until its result is actually needed.

<Example><![CDATA[
gap> task1 := DelayTask(Product, [1..5000]);;
gap> task2 := DelayTask(Product, [5001
ap> WaitTask(task1, task2);
gap> TaskResult(task1) * TaskResult(task2) = Factorial(10000);
true
]]></Example>

Note that <Ref Func]]</Example>
started until <C>TaskResult(task1)</C> has been evaluated.
P/
start executionof a  ,you   use <ExecuteTask<C>    effectif a   already been
gap (task1)*TaskResulttask2)=Factorial10000)
t
For ,you canalso <Ref ="">toexecute  task(.,thetask isstarted
immediately

<start  bothtasks otherwise Ctask2<>would 
gap> task := ImmediateTask(x -started  <>TaskResulttask1)<>evaluated.
TaskResulttask)
, 3 ]
]</java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4

 task : ImmediateTask- (),[3,2,1];java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
P>
Thisis  from callingfunctiondirectly but provides  sameinterfaceas  tasks.
Such a task cannot be waited for and its result (if any) is ignored.

<Log><![CDATA[
gap> RunAsyncTask(Such a task cannot be wait anditsresult ( any)  ignored.
gap> !list
---  java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 25
-For informationonthe multithreaded user interface   <RefChap="Console  Interface"/.
gap arguments are  copiedso that     createdthem and the task that uses them  access 
---  thread5
[relevantpartsof  <ef Sect=Migratingobjectsregions/   objectsbetweenregions;sharedandpublicarguments will   copied.
!0
--- Switching to thread 0
gap>
]]></Log>

 more   the multi- user interface   <ef Chap=ConsoleUser Interface">
</
arguments generallycopiedso thatboththe  created   the taskthat them  accessthe
     race conditions.Toavoidcopying  shouldbemade  or public s 
<Section="Running "
P>
HPCGAP currentlyhas multiple implementationsofthe API   an alternativeimplementation to theone  ,set the
      Func =RunTask =func [ arg1 .,argn]
  <>

  <Section Label="Running tasks">
    <Heading>        <Ref FuncRunTask/   task execution and starts it. The task will call the function <A>func</A> with arguments
    <ManSection>
      <Func Name="RunTask" Arg='func [, arg1, ..., argn]'/>
      <>
      />
<>rg1/>through<><>(f provided)     Af<A is the result ofthe .

        The <Ref Func='RunTask'/> call itself returns 
      />
    </ManSection>

    <ManSection>
      <Description
      <        <Ref=ScheduleTask' prepares a  forexecution,but,unlike <ef 'RunTask'>does start it  <>ondition/>
        <Ref Func='ScheduleTask'/> prepares a task for execution, but, unlike <Ref Func='RunTask'/> does         .  on toconstructconditions Simpleexamples   areindividualtasks,whereexecutionoccursafter
        final task until theothers arecomplete it moreefficient,since noadditionalworker   tobe
        the task completes, or lists of tasks, where execution occurs after all tasks in the list java.lang.StringIndexOutOfBoundsException: Index 104 out of bounds for length 17

        <Example><![CDATA[
gap  : RunTaskx>*,3);
gap> t2       RefFunc=DelayTask"/works  <ef =RunTask"/,butitsstartisdelayed  it being waitedfor (
> t: ([t1, t2] (java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
urn ()+ TaskResult(2)
>    end);;
gap>  <uncName""Arg' [ ,.., ]/

] < Func=RunAsyncTask>creates  asynchronoustask. Itworks like <efFunc="unTask"/,except that  will be
        While the        ignoredjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
       RFunc=TaskResult/  wait  At1< <><A>tocomplete the above implementation   actually start
        the final task until the others are complete, making it more efficient, since no additional<escriptionjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
        .

      </Description>
    </except   will be ignoredjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47

    ManSectionjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
arg1 .,'>
      <Description>
      <>
      implicitly by calling <Ref Func="TaskResult"/>).
      </Description>
    </ManSection>

    <ManSection>
      Func ="Arg=func [,arg1,.. ]'/>
      <Description      <Description>
        <java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
       .
      </Description>
          <>
        <ef Func"/>executes the task specified byits  synchronously, within   .
    <ManSection>
      <Func Name="ScheduleAsyncTask" Arg='condition, func,      /Description>
<anSection
< =ScheduleAsyncTaskcreatesan task workslike<efFunc="">
        except that its result      D
      <Description
    </ManSection>

    <ManSection>
      <Func Name="MakeTaskAsync" Arg='task'/>
          /ManSection>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        be 
      </Description>
    </ManSection       Name"aitTask =''Label="ith a "/>

    <ManSection>
      <Func       Func="aitTasks Arg',.,'/>
      <Description>
        <java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
      <Descriptionjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
    <ManSection>

    <
      <
      <Descriptionjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
        <anSection>
returned by Ref =DelayTask"> java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 70
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="WaitTask" Arg='task1,...,taskn'/>
      <Func Name="WaitTask" Arg='condition' Label="with a condition" />
      <Func Name="WaitTasks" Arg='task1,...,taskn'/>

      <Description>
        <Ref Func="WaitTask"/> waits until <A>        The <Ref Func="WaitAnyTask"/> function waits  of its  to java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17

 of ,  message can be retrieved via <Ref Func="TaskError"/.
        construct conditions.

        <Ref Func="WaitTasks"/> is an alias for <Ref Func="WaitTask"/>.
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="   <anSection>
      D>
        Description>

![DATA[
>task1: (->ortedListx)[,21);
gap> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
gap> which :    M>
2
gap>      Description>
>      Display(TaskResult(task1));Display(TaskResult(task2));
>    else
>      (TaskResult(task2);((task1);
>    fi;
[4 ,6]
[ 1, 2, 3 ]
]]></Example>

          Otherwise the functionreturns<>alse<Kjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
identically to<>(,..,taskn)/>.

      <unc Name= Arg=task'>
     <>

    >
      <Func            ,ifit encounteredan .
      <Description>
        The <Ref Func="            did   error    <fail<K>
        </ManSection
        
        <P<ManSection>
functionby<task<>encounters  error,Ref FuncTaskResult">returns <fjava.lang.StringIndexOutOfBoundsException: Index 114 out of bounds for length 114
Whether<task/> anerror canbe   Ref "">
        In case of an error, the error message encounteringanerror.
      />
    </ManSection>

    <   </>
<>
      <Descriptionjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
       function unusedworker threadsjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
      </Description>
    </ManSection>
  </Section>

  <Section Label="Information about tasks">
    <Heading>Information about tasks</Heading>
    <ManSection>
      <Func Name="TaskSuccess" Arg='task'/>
      <Description>
          <Ref Func="TaskSuccess"/> waits for <A>task</A> and returns
          <K>true</K> if the it finished without encountering an error.
          Otherwise the function returns <K>false</K>.
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="TaskError" Arg='task'/>
      <Description>
        <Ref Func="TaskError"/> waits for <A>task</A> and returns
          its error message, if it encountered an error.
          If it did not encounter an error, the function returns <K>fail</K>.
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="CurrentTask" Arg=''/>
      <Description>
        The <Ref Func="CurrentTask"/> returns the currently running task.
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="RunningTasks" Arg=''/>
      <Description>
        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.
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="TaskStarted" Arg='task'/>
      <Description>
        This function returns true if the task has started executing (i.e., for any non-delayed task), false otherwise.
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="TaskFinished" Arg='task'/>
      <Description>
        This function returns true if the task has finished executing and its result is available, false otherwise.
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="TaskIsAsync" Arg='task'/>
      <Description>
        This function returns true if the task is asynchronous, true otherwise.
      </Description>
    </ManSection>
  </Section>

  <Section Label="Cancelling tasks">
    <Heading>Cancelling tasks</Heading>
    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.

    <ManSection>
      <Func Name="CancelTask" Arg='task'/>
      <Description>
        <Ref Func="CancelTask"/> submits a request that <A>task</A> is to be cancelled.
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="TaskCancellationRequested" Arg='task'/>
      <Description>
        <Ref Func="TaskCancellationRequested"/> returns true if <Ref Func="CancelTask"/> has been called for <A>task</A>,
        false otherwise.
      </Description>
    </ManSection>

    <ManSection>
      <Func Name="OnTaskCancellation" Arg='exit_func'/>
      <Description>
        <Ref Func="OnTaskCancellation"/> tests if cancellation for the current task has been requested. If so,
        then <A>exit_func</A> 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 <A>exit_func()/A>

le<CDATAjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
gap> task := RunTask(function()
>      while true do
>        OnTaskCancellation(function() return 314; end);
>     ;
>    end);;
gap>CancelTask(ask)
gap>TaskResulttask;
 <ManSection>
]]></Example>
      </Description>
    </ManSection>

    <java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
      <unc Name"" Arg='alue'>
      <Description>
        <Ref         The <Ref Func <efFunc"">returnsthecurrentlyrunningtask.
        n<ManSection
      </java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 16
    </<java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19

  </Section>

  <Section Label="Conditions">
    <Conditions/eading>

    <Ref FuncScheduleTask"/> and <Ref Func="java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 20
A iseithera a  a  if  started (e,for  nondelayed ,false.
task<FuncWaitTask/ when the condition has  ()
    conditiona ismetjava.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 75
    />
    ajava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 122
  /

S =Milestones>
    <test  the       Func""=alue/

Milestonesare   abstract  multiple contribute

    <ManSection>
      "Arg'list'>
            /
        <anSection
t     integers /java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 0
      <>
           "Argtask'java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57

   ManSection .
      <<=WaitTask
n
       
e    amilestoneismetwhen hasbeenachieved seebelow.Acondition java.lang.StringIndexOutOfBoundsException: Index 117 out of bounds for length 55
      </Descriptionalist      Description
    tion

<
    Heading><java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 33
<java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
         ef=AchieveMilestone>allowsa achieve java.lang.StringIndexOutOfBoundsException: Range [92, 91) out of bounds for length 108
         adding java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 20
        Ref=NewMilestone"<
<Example>od
  =;
         mustbelistof integers / strings gap TaskResult()
]
      on
    </ManSection<

     <Description>
      <Func Name="IsMilestoneAchieved" Arg='milestone'/>
      <Description>
        <Ref Func="IsMilestoneAchieved"/> tests explicitly if a milestone has been achieved. It returns
        <K>true</K> on success, <K>false</K> otherwise.
<Example><!     <escription>
m  beenachievedjava.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 0
gap m;
false
gap>(,)
gap>         The <Ref Func="Achie"  allowsa toachievea  in single java.lang.StringIndexOutOfBoundsException: Index 108 out of bounds for length 108
true
]]></Example>
      </DescriptionR =NewMilestone> .java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
    </ManSection>
  </Section>
</Chapter>

Messung V0.5 in Prozent
C=98 H=73 G=86

¤ Dauer der Verarbeitung: 0.293 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.