cvs: phpdoc /en/reference/misc/functions time-nanosleep.xml

From: Date: Tue, 10 Aug 2004 18:45:07 +0000
Subject: cvs: phpdoc /en/reference/misc/functions time-nanosleep.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969363008@lists.php.net to get a copy of this message
dave Tue Aug 10 14:45:07 2004 EDT Modified files: /phpdoc/en/reference/misc/functions time-nanosleep.xml Log: - Document time_nanosleep(), with example. http://cvs.php.net/diff.php/phpdoc/en/reference/misc/functions/time-nanosleep.xml?r1=1.1&r2=1.2&ty=u Index: phpdoc/en/reference/misc/functions/time-nanosleep.xml diff -u phpdoc/en/reference/misc/functions/time-nanosleep.xml:1.1 phpdoc/en/reference/misc/functions/time-nanosleep.xml:1.2 --- phpdoc/en/reference/misc/functions/time-nanosleep.xml:1.1 Sun May 2 11:46:21 2004 +++ phpdoc/en/reference/misc/functions/time-nanosleep.xml Tue Aug 10 14:45:07 2004 @@ -1,22 +1,99 @@ <?xml version='1.0' encoding='iso-8859-1'?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="function.time-nanosleep"> <refnamediv> <refname>time_nanosleep</refname> <refpurpose> - Delay for a number of seconds and nano seconds + Delay for a number of seconds and nanoseconds </refpurpose> </refnamediv> <refsect1> - <title>Description</title> + &reftitle.description; <methodsynopsis> <type>mixed</type><methodname>time_nanosleep</methodname> <methodparam><type>int</type><parameter>seconds</parameter></methodparam> <methodparam><type>int</type><parameter>nanoseconds</parameter></methodparam> </methodsynopsis> + <para> + Delays program execution for the given number of + <parameter>seconds</parameter> and <parameter>nanoseconds</parameter>. + </para> + <para> + <parameter>seconds</parameter> must be a positive integer, and + <parameter>nanoseconds</parameter> must be a positive integer less than + 1 billion. + </para> + </refsect1> + <refsect1> + &reftitle.returnvalues; + <para> + Returns &true; on success, &false; on failure. + </para> + <para> + If the delay was interrupted by a signal, an associative array will be + returned with the components: + <itemizedlist> + <listitem> + <simpara> + <literal>seconds</literal> - number of seconds remaining in + the delay + </simpara> + </listitem> + <listitem> + <simpara> + <literal>nanoseconds</literal> - number of nanoseconds + remaining in the delay + </simpara> + </listitem> + </itemizedlist> + </para> + </refsect1> + <refsect1> + &reftitle.seealso; + <para> + <function>sleep</function>, + <function>usleep</function>, + <function>set_time_limit</function> + </para> + </refsect1> + <refsect1> + &reftitle.examples; + <para> + <example> + <title><function>time_nanosleep</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +/* Careful! This won't work as expected if an array is returned */ +if (time_nanosleep(0, 500000)) { + echo "Slept for half a second.\n"; +} + +/* This is better: */ +if (time_nanosleep(0, 500000) === true) { + echo "Slept for half a second.\n"; +} - &warn.undocumented.func; +/* And this is the best: */ +$nano = time_nanosleep(2, 100000); +if ($nano === true) { + echo "Slept for 2 seconds, 100 milliseconds.\n"; +} +else if ($nano === false) { + echo "Sleeping failed.\n"; +} +else if (is_array($nano)) { + $seconds = $nano['seconds']; + $nanoseconds = $nano['nanoseconds']; + echo "Interrupted by a signal.\n"; + echo "Time remaining: $seconds seconds, $nanoseconds nanoseconds."; +} +?> +]]> + </programlisting> + </example> + </para> </refsect1> </refentry>

« previous php.doc (#969363008) next »