reference/misc/functions/usleep.xml
3441bb1c988fac320d7f436b2c06b88899a6b121
...
...
@@ -10,7 +10,7 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>void</type><methodname>usleep</methodname>
13
-
<methodparam><type>int</type><parameter>micro_seconds</parameter></methodparam>
13
+
<methodparam><type>int</type><parameter>microseconds</parameter></methodparam>
14
14
</methodsynopsis>
15
15
<para>
16
16
Delays program execution for the given number of microseconds.
...
...
@@ -22,12 +22,24 @@
22
22
<para>
23
23
<variablelist>
24
24
<varlistentry>
25
-
<term><parameter>micro_seconds</parameter></term>
25
+
<term><parameter>microseconds</parameter></term>
26
26
<listitem>
27
27
<para>
28
28
Halt time in microseconds. A microsecond is one millionth of a
29
29
second.
30
30
</para>
31
+
<note>
32
+
<simpara>
33
+
Values larger than <literal>1000000</literal> (i.e. sleeping for more than a second)
34
+
may not be supported by the operating system. Use <function>sleep</function> instead.
35
+
</simpara>
36
+
</note>
37
+
<note>
38
+
<simpara>
39
+
The sleep may be lengthened slightly (i.e. may be longer than <parameter>microseconds</parameter>)
40
+
by any system activity or by the time spent processing the call or by the granularity of system timers.
41
+
</simpara>
42
+
</note>
31
43
</listitem>
32
44
</varlistentry>
33
45
</variablelist>
...
...
@@ -51,13 +63,19 @@
51
63
<?php
52
64

53
65
// Current time
54
-
echo date('h:i:s') . "\n";
66
+
echo (new DateTime('now'))->format('H:i:s.v'), "\n";
55
67

56
-
// wait for 2 seconds
57
-
usleep(2000000);
68
+
// wait for 2 milliseconds
69
+
usleep(2000);
58
70

59
71
// back!
60
-
echo date('h:i:s') . "\n";
72
+
echo (new DateTime('now'))->format('H:i:s.v'), "\n";
73
+

74
+
// wait for 30 milliseconds
75
+
usleep(30000);
76
+

77
+
// back again!
78
+
echo (new DateTime('now'))->format('H:i:s.v'), "\n";
61
79

62
80
?>
63
81
]]>
...
...
@@ -65,8 +83,9 @@ echo date('h:i:s') . "\n";
65
83
&example.outputs;
66
84
<screen>
67
85
<![CDATA[
68
-
11:13:28
69
-
11:13:30
86
+
11:13:28.005
87
+
11:13:28.007
88
+
11:13:28.037
70
89
]]>
71
90
</screen>
72
91
</example>
...
...
@@ -86,7 +105,6 @@ echo date('h:i:s') . "\n";
86
105
</refsect1>
87
106

88
107
</refentry>
89
-

90
108
<!-- Keep this comment at the end of the file
91
109
Local variables:
92
110
mode: sgml
93
111