<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/refs.fileprocess.process.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'book.eio.php',
    1 => 'Eio',
    2 => 'Eio',
  ),
  'up' => 
  array (
    0 => 'refs.fileprocess.process.php',
    1 => 'Extensions sur le contr&ocirc;le des processus',
  ),
  'prev' => 
  array (
    0 => 'refs.fileprocess.process.php',
    1 => 'Extensions sur le contr&ocirc;le des processus',
  ),
  'next' => 
  array (
    0 => 'eio.setup.php',
    1 => 'Installation/Configuration',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/eio/book.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/book.eio.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="book.eio" class="book">
 
 <h1 class="title">Eio</h1>
 

 <div id="intro.eio" class="preface">
  <h1 class="title">Introduction</h1>
  <p class="simpara">
   Cette extension fournit un système POSIX I/O asynchrone via
   la bibliothèque C <a href="http://software.schmorp.de/pkg/libeio.html" class="link external">&raquo;&nbsp;libeio</a>
   écrite par Marc Lehmann.
  </p>

  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">
 Cette extension n&#039;est pas disponible sur les plates-formes Windows.
</span></p></blockquote>

  <p class="para">

  <div class="warning"><strong class="warning">Avertissement</strong>
  <p class="simpara">
   Il est important de noter que chaque demande est exécutée dans un thread,
   et l&#039;ordre d&#039;exécution des demandes en attente n&#039;est pas assuré.
   Pour l&#039;instant, le code suivant n&#039;est pas correct.
  </p>
  </div>

  <div class="example" id="example-1">
  <p><strong>Exemple #1 Demandes incorrectes</strong></p>
  <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Demande la création d'un lien symbolique $filename vers $link<br /></span><span style="color: #0000BB">eio_symlink</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Demande de déplacement de $filename vers $new_filename<br /></span><span style="color: #0000BB">eio_rename</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #0000BB">$new_filename</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Exécution des demandes<br /></span><span style="color: #0000BB">eio_event_loop</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   </div>
   Dans l&#039;exemple ci-dessus, la fonction <span class="function"><a href="function.eio-rename.php" class="function">eio_rename()</a></span>
   peut se terminer avant la fonction <span class="function"><a href="function.eio-symlink.php" class="function">eio_symlink()</a></span>.
   Pour résoudre ce problème, il est possible d&#039;appeler la fonction
   <span class="function"><a href="function.eio-rename.php" class="function">eio_rename()</a></span> dans la fonction de rappel de la
   fonction <span class="function"><a href="function.eio-symlink.php" class="function">eio_symlink()</a></span>:
  <div class="example" id="example-2">
   <p><strong>Exemple #2 Exécution d&#039;une demande dans la fonction de rappel d&#039;une autre</strong></p>
   <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">my_symlink_done</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #0000BB">$result</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// Demande de déplacement de $filename vers $new_filename<br /> </span><span style="color: #0000BB">eio_rename</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #DD0000">"/path/to/new-name"</span><span style="color: #007700">);<br /><br /> </span><span style="color: #FF8000">// Exécution des demandes<br /> </span><span style="color: #0000BB">eio_event_loop</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #FF8000">// Demande de création d'un lien symbolique $filename vers $link<br /></span><span style="color: #0000BB">eio_symlink</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #0000BB">$link</span><span style="color: #007700">, </span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_symlink_done"</span><span style="color: #007700">, </span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Exécution des demandes<br /></span><span style="color: #0000BB">eio_event_loop</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>

   Alternativement, il est possible de créer un groupe de demandes :

  <div class="example" id="example-3">
   <p><strong>Exemple #3 Exécution d&#039;une demande depuis la fonction de rappel d&#039;une autre</strong></p>
   <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Sera appelé lorsque le groupe de demandes aura terminé */<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">my_grp_done</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">, </span><span style="color: #0000BB">$result</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// ...<br /></span><span style="color: #007700">}<br /><br />function </span><span style="color: #0000BB">my_symlink_done</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #0000BB">$result</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// Crée une demande eio_rename et l'ajoute au groupe<br /> </span><span style="color: #0000BB">$req </span><span style="color: #007700">= </span><span style="color: #0000BB">eio_rename</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #DD0000">"/path/to/new-name"</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">eio_grp_add</span><span style="color: #007700">(</span><span style="color: #0000BB">$grp</span><span style="color: #007700">, </span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br /> </span><span style="color: #FF8000">// Vous pouvez vouloir d'autres actions...<br /></span><span style="color: #007700">}<br /><br /></span><span style="color: #FF8000">// Création d'un groupe de demandes<br /></span><span style="color: #0000BB">$grp </span><span style="color: #007700">= </span><span style="color: #0000BB">eio_grp</span><span style="color: #007700">(</span><span style="color: #DD0000">"my_grp_done"</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_grp_data"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Crée une demande eio_symlink et l'ajoute au groupe<br />// Passage de $filename à la fonction de rappel<br /></span><span style="color: #0000BB">$req </span><span style="color: #007700">= </span><span style="color: #0000BB">eio_symlink</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #0000BB">$link</span><span style="color: #007700">,<br />  </span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_symlink_done"</span><span style="color: #007700">, </span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">eio_grp_add</span><span style="color: #007700">(</span><span style="color: #0000BB">$grp</span><span style="color: #007700">, </span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Exécution des demandes<br /></span><span style="color: #0000BB">eio_event_loop</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></div>

  </div>
   Un groupe est une demande spéciale qui peut cumuler un jeu de
   demandes <em>eio</em>. Ce mécanisme peut être utile pour
   créer une demande complexe qui ouvre, lit et ferme un fichier.
  </p>
  <p class="para">
   À partir de la version 0.3.0 alpha, une variable utilisée dans les
   communications internes avec libeio peut être récupérée
   avec la fonction <span class="function"><a href="function.eio-get-event-stream.php" class="function">eio_get_event_stream()</a></span>. La
   variable peut être utilisée pour lier une boucle d&#039;événements
   avec d&#039;autres extensions. Il est possible d&#039;organiser une boucle
   d&#039;événements où libeio et libevent fonctionnent ensemble :
  <div class="example" id="example-4">
   <p><strong>Exemple #4 Utilisation d&#039;eio et libevent</strong></p>
   <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">my_eio_poll</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">, </span><span style="color: #0000BB">$events</span><span style="color: #007700">, </span><span style="color: #0000BB">$arg</span><span style="color: #007700">) {<br />    </span><span style="color: #FF8000">/* Quelques régulations libevent peuvent venir ici .. */<br />    </span><span style="color: #007700">if (</span><span style="color: #0000BB">eio_nreqs</span><span style="color: #007700">()) {<br />        </span><span style="color: #0000BB">eio_poll</span><span style="color: #007700">();<br />    }<br />    </span><span style="color: #FF8000">/* .. et ici */<br /></span><span style="color: #007700">}<br /><br />function </span><span style="color: #0000BB">my_res_cb</span><span style="color: #007700">(</span><span style="color: #0000BB">$d</span><span style="color: #007700">, </span><span style="color: #0000BB">$r</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">); </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$d</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$base </span><span style="color: #007700">= </span><span style="color: #0000BB">event_base_new</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$event </span><span style="color: #007700">= </span><span style="color: #0000BB">event_new</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// Ce flux est utilisé pour se lier avec libevent<br /></span><span style="color: #0000BB">$fd </span><span style="color: #007700">= </span><span style="color: #0000BB">eio_get_event_stream</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">eio_nop</span><span style="color: #007700">(</span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_res_cb"</span><span style="color: #007700">, </span><span style="color: #DD0000">"nop data"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">eio_mkdir</span><span style="color: #007700">(</span><span style="color: #DD0000">"/tmp/abc-eio-temp"</span><span style="color: #007700">, </span><span style="color: #0000BB">0750</span><span style="color: #007700">, </span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_res_cb"</span><span style="color: #007700">, </span><span style="color: #DD0000">"mkdir data"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">/* d'autres appels eio_* ici ... */<br /><br /><br />// Définit les drapeaux des événements<br /></span><span style="color: #0000BB">event_set</span><span style="color: #007700">(</span><span style="color: #0000BB">$event</span><span style="color: #007700">, </span><span style="color: #0000BB">$fd</span><span style="color: #007700">, </span><span style="color: #0000BB">EV_READ </span><span style="color: #FF8000">/*| EV_PERSIST*/</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_eio_poll"</span><span style="color: #007700">, array(</span><span style="color: #0000BB">$event</span><span style="color: #007700">, </span><span style="color: #0000BB">$base</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Définit l'événement de base<br /></span><span style="color: #0000BB">event_base_set</span><span style="color: #007700">(</span><span style="color: #0000BB">$event</span><span style="color: #007700">, </span><span style="color: #0000BB">$base</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Active l'événement<br /></span><span style="color: #0000BB">event_add</span><span style="color: #007700">(</span><span style="color: #0000BB">$event</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Démarre la boucle des événements<br /></span><span style="color: #0000BB">event_base_loop</span><span style="color: #007700">(</span><span style="color: #0000BB">$base</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* La même chose est disponible via l'interface libevent bufferisée */<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></div>

  </div>

  </p>
 </div>

 






 






 







 









<ul class="chunklist chunklist_book"><li><a href="eio.setup.php">Installation/Configuration</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="eio.requirements.php">Pr&eacute;-requis</a></li><li><a href="eio.installation.php">Installation</a></li><li><a href="eio.resources.php">Types de ressources</a></li></ul></li><li><a href="eio.constants.php">Constantes pr&eacute;-d&eacute;finies</a></li><li><a href="eio.examples.php">Exemples</a></li><li><a href="ref.eio.php">Fonctions Eio</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="function.eio-busy.php">eio_busy</a> — Augmente artificiellement la charge. Utile dans le cadre de tests</li><li><a href="function.eio-cancel.php">eio_cancel</a> — Annule une requ&ecirc;te</li><li><a href="function.eio-chmod.php">eio_chmod</a> — Modifie les permissions d'un fichier/dossier</li><li><a href="function.eio-chown.php">eio_chown</a> — Modifie les permissions d'un fichier/dossier</li><li><a href="function.eio-close.php">eio_close</a> — Ferme un fichier</li><li><a href="function.eio-custom.php">eio_custom</a> — Ex&eacute;cute une demande personnalis&eacute;e comme l'appel &agrave; une des fonctions eio_*</li><li><a href="function.eio-dup2.php">eio_dup2</a> — Duplique un descripteur de fichier</li><li><a href="function.eio-event-loop.php">eio_event_loop</a> — Boucle libeio tant que les requ&ecirc;tes s'ex&eacute;cutent</li><li><a href="function.eio-fallocate.php">eio_fallocate</a> — Autorise l'appelant &agrave; manipuler directement l'espace disque allou&eacute; pour un fichier</li><li><a href="function.eio-fchmod.php">eio_fchmod</a> — Modifie les permissions sur un fichier</li><li><a href="function.eio-fchown.php">eio_fchown</a> — Modifie le propri&eacute;taire du fichier</li><li><a href="function.eio-fdatasync.php">eio_fdatasync</a> — Synchronise le statut interne d'un fichier avec le p&eacute;riph&eacute;rique de stockage</li><li><a href="function.eio-fstat.php">eio_fstat</a> — R&eacute;cup&egrave;re le statut d'un fichier</li><li><a href="function.eio-fstatvfs.php">eio_fstatvfs</a> — R&eacute;cup&egrave;re des statistiques sur le syst&egrave;me de fichiers</li><li><a href="function.eio-fsync.php">eio_fsync</a> — Synchronise le statut interne d'un fichier avec le p&eacute;riph&eacute;rique de stockage</li><li><a href="function.eio-ftruncate.php">eio_ftruncate</a> — Tronque un fichier</li><li><a href="function.eio-futime.php">eio_futime</a> — Modifie l'heure du dernier acc&egrave;s et de la derni&egrave;re modification d'un fichier</li><li><a href="function.eio-get-event-stream.php">eio_get_event_stream</a> — R&eacute;cup&egrave;re le flux repr&eacute;sentant une variable utilis&eacute;e dans les communications internes avec libeio</li><li><a href="function.eio-get-last-error.php">eio_get_last_error</a> — Retourne une cha&icirc;ne d&eacute;crivant la derni&egrave;re erreur associ&eacute;e avec la ressource demand&eacute;e</li><li><a href="function.eio-grp.php">eio_grp</a> — Cr&eacute;e un groupe de requ&ecirc;tes</li><li><a href="function.eio-grp-add.php">eio_grp_add</a> — Ajoute une requ&ecirc;te au groupe de requ&ecirc;tes</li><li><a href="function.eio-grp-cancel.php">eio_grp_cancel</a> — Annule un groupe de requ&ecirc;tes</li><li><a href="function.eio-grp-limit.php">eio_grp_limit</a> — D&eacute;finit la limite d'un groupe</li><li><a href="function.eio-init.php">eio_init</a> — (Re-)initialise Eio</li><li><a href="function.eio-link.php">eio_link</a> — Cr&eacute;e un lien fort sur un fichier</li><li><a href="function.eio-lstat.php">eio_lstat</a> — R&eacute;cup&egrave;re le statut d'un fichier</li><li><a href="function.eio-mkdir.php">eio_mkdir</a> — Cr&eacute;e un dossier</li><li><a href="function.eio-mknod.php">eio_mknod</a> — Cr&eacute;e un fichier sp&eacute;cial ou ordinaire</li><li><a href="function.eio-nop.php">eio_nop</a> — Ne fait rien, mis &agrave; part le fait de parcourir l'ensemble du cycle des requ&ecirc;tes</li><li><a href="function.eio-npending.php">eio_npending</a> — Retourne le nombre de requ&ecirc;tes termin&eacute;es</li><li><a href="function.eio-nready.php">eio_nready</a> — Retourne le nombre de requ&ecirc;tes pas encore g&eacute;r&eacute;es</li><li><a href="function.eio-nreqs.php">eio_nreqs</a> — Retourne le nombre de requ&ecirc;tes restant &agrave; ex&eacute;cuter</li><li><a href="function.eio-nthreads.php">eio_nthreads</a> — Retourne le nombre de threads actuellement utilis&eacute;s</li><li><a href="function.eio-open.php">eio_open</a> — Ouvre un fichier</li><li><a href="function.eio-poll.php">eio_poll</a> — V&eacute;rifie s'il reste des requ&ecirc;tes en cours d'ex&eacute;cution</li><li><a href="function.eio-read.php">eio_read</a> — Lit un descripteur de fichier &agrave; une position donn&eacute;e</li><li><a href="function.eio-readahead.php">eio_readahead</a> — Effectue un readahead sur le fichier dans le cache d'une page</li><li><a href="function.eio-readdir.php">eio_readdir</a> — Lit le contenu d'un dossier</li><li><a href="function.eio-readlink.php">eio_readlink</a> — Lit la valeur d'un lien symbolique</li><li><a href="function.eio-realpath.php">eio_realpath</a> — R&eacute;cup&egrave;re le nom du chemin absolu canonis&eacute;</li><li><a href="function.eio-rename.php">eio_rename</a> — Modifie le nom ou le chemin d'un fichier</li><li><a href="function.eio-rmdir.php">eio_rmdir</a> — Supprime un dossier</li><li><a href="function.eio-seek.php">eio_seek</a> — Repositionne le curseur d'un fichier ouvert</li><li><a href="function.eio-sendfile.php">eio_sendfile</a> — Transf&egrave;re des donn&eacute;es entre des descripteurs de fichiers</li><li><a href="function.eio-set-max-idle.php">eio_set_max_idle</a> — D&eacute;finit le nombre maximal de threads inactifs</li><li><a href="function.eio-set-max-parallel.php">eio_set_max_parallel</a> — D&eacute;finit le nombre maximal de threads en parall&egrave;le</li><li><a href="function.eio-set-max-poll-reqs.php">eio_set_max_poll_reqs</a> — D&eacute;finit le nombre maximal de requ&ecirc;tes &agrave; ex&eacute;cuter dans une file d'attente</li><li><a href="function.eio-set-max-poll-time.php">eio_set_max_poll_time</a> — D&eacute;finit la dur&eacute;e maximale de la file d'attente</li><li><a href="function.eio-set-min-parallel.php">eio_set_min_parallel</a> — D&eacute;finit le nombre minimum de threads parall&egrave;les</li><li><a href="function.eio-stat.php">eio_stat</a> — R&eacute;cup&egrave;re le statut d'un fichier</li><li><a href="function.eio-statvfs.php">eio_statvfs</a> — R&eacute;cup&egrave;re les statistiques du syst&egrave;me de fichiers</li><li><a href="function.eio-symlink.php">eio_symlink</a> — Cr&eacute;e un lien symbolique</li><li><a href="function.eio-sync.php">eio_sync</a> — Valide le cache du buffer sur le disque</li><li><a href="function.eio-sync-file-range.php">eio_sync_file_range</a> — Synchronise un segment de fichier avec le disque</li><li><a href="function.eio-syncfs.php">eio_syncfs</a> — Appelle la fonction syst&egrave;me Linux syncfs, si disponible</li><li><a href="function.eio-truncate.php">eio_truncate</a> — Tronque un fichier</li><li><a href="function.eio-unlink.php">eio_unlink</a> — Supprime un nom et &eacute;ventuellement, le fichier qui s'y r&eacute;f&egrave;re</li><li><a href="function.eio-utime.php">eio_utime</a> — Modifie l'heure du dernier acc&egrave;s et de la derni&egrave;re modification d'un fichier</li><li><a href="function.eio-write.php">eio_write</a> — &Eacute;crit dans un fichier</li></ul></li></ul></div><?php manual_footer($setup); ?>