Difference between revisions of "Lib/sequencer offers Multitasking"

From Liberty Eiffel Wiki
Jump to navigation Jump to search
(still translating)
(still translating)
Line 21: Line 21:
 
Also, the loops stack is composed of many execution loops ([[library_class:LOOP_ITEM|<tt>LOOP_ITEM</tt>]]). This allows, for instance, the implementation of a kind of ''modality'' (see the modal windows in [[lib/vision|Vision]]).
 
Also, the loops stack is composed of many execution loops ([[library_class:LOOP_ITEM|<tt>LOOP_ITEM</tt>]]). This allows, for instance, the implementation of a kind of ''modality'' (see the modal windows in [[lib/vision|Vision]]).
   
  +
== Tasks ==
<!--
 
== Les tâches ==
 
   
Une tâche a un cycle de vie qui se représente par les méthodes qui sont exécutées par le gestionnaire (en fait un [[library_class:LOOP_ITEM|<tt>LOOP_ITEM</tt>]] d'où les clauses d'export de ces fonctions).
+
A task has a life cycle represented by the features executed by the manager (indeed a [[library_class:LOOP_ITEM|<tt>LOOP_ITEM</tt>]] hence the export clauses of those fetaures).
   
# <tt>prepare</tt> permet de préparer la tâche&nbsp;; dans cette phase, la tâche positionne les événements sur lesquels elle souhaite être activée. L'objet [[library_class:READY_DESCRIPTION|<tt>READY_DESCRIPTION</tt>]] est un objet sur lequel on peut positionner des conditions (grâces à ses méthodes <tt>when_*</tt>).
+
# <tt>prepare</tt> allows to prepare the task; in this phase, the task sets the events upon which it wants to be activated. The [[library_class:READY_DESCRIPTION|<tt>READY_DESCRIPTION</tt>]] object is an object upon which one can set conditions (thanks to its <tt>when_*</tt> features).
# <tt>is_ready</tt> permet de tester si la tâche a vraiment été activée. L'objet [[library_class:READY_DESCRIPTION|<tt>READY_DESCRIPTION</tt>]] est un objet sur lequel on peut tester des conditions (grâces à ses méthodes <tt>is_*</tt>).
+
# <tt>is_ready</tt> allows to test if the task has really been activated.The [[library_class:READY_DESCRIPTION|<tt>READY_DESCRIPTION</tt>]] object is an object upon which one can test conditions (thanks to its <tt>is_*</tt> features).
# <tt>continue</tt> contient le corps de l'exécution de la tâche, si celle-ci est effectivement activée.
+
# <tt>continue</tt> contains the execution body of the task, and is executed if the task is really activated.
# <tt>done</tt> permet de dire si la tâche a terminé de s'exécuter. Dans ce cas, elle sera supprimée de la boucle d'exécution. Dans le cas contraire, le cycle recommence.
+
# <tt>done</tt> tells if the task has finished its execution. If so, it will be removed from the execution loop. Otherwise, the cycle begins again.
# <tt>restart</tt> permet de réinjecter une tâche dans la boucle d'exécution.
+
# <tt>restart</tt> allows to reinsert a task in the execution loop.
   
La fonction <tt>restart</tt> est rarement utile. Voir [[lib/vision|Vision]] pour des exemples d'utilisation.
+
The <tt>restart</tt> feature is seldom useful. See [[lib/vision|Vision]] for some use cases.
   
  +
<!--
 
== Conditions d'exécution ==
 
== Conditions d'exécution ==
   

Revision as of 15:45, 4 January 2006

*** OK, I'm translating that --Cyril 14:34, 4 Jan 2006 (CET)

The lib/sequencer library implements one kind of cooperative multi-tasking of the event-driver kind. Unlike "pure" cooperative multi-tasking, a task cannot stop at any time (using an hypothetic yield feature) but only in lnown and stable states. That is conform to the Eiffel principles.

The principle is:

  • the class LOOP_STACK manages the multi-tasking;
  • the class JOB represents a task. The task core is the continue feature, in which the task controls the whole system;
  • the class READY_DESCRIPTION allows to describe in which conditions a task can be executed.

We will successively see each of those concepts.

The multi-tasking manager

The class LOOP_STACK is in charge of managing the multi-tasking. It is used in two steps:

  • initialisation: creation of the LOOP_STACK object, and adding of the tasks to execute
  • execution: execution of the run feature

Of course, tasks can be added during the execution. The manager can also be stopped, thanks to the break feature.

Also, the loops stack is composed of many execution loops (LOOP_ITEM). This allows, for instance, the implementation of a kind of modality (see the modal windows in Vision).

Tasks

A task has a life cycle represented by the features executed by the manager (indeed a LOOP_ITEM hence the export clauses of those fetaures).

  1. prepare allows to prepare the task; in this phase, the task sets the events upon which it wants to be activated. The READY_DESCRIPTION object is an object upon which one can set conditions (thanks to its when_* features).
  2. is_ready allows to test if the task has really been activated.The READY_DESCRIPTION object is an object upon which one can test conditions (thanks to its is_* features).
  3. continue contains the execution body of the task, and is executed if the task is really activated.
  4. done tells if the task has finished its execution. If so, it will be removed from the execution loop. Otherwise, the cycle begins again.
  5. restart allows to reinsert a task in the execution loop.

The restart feature is seldom useful. See Vision for some use cases.