reference/misc/functions/usleep.xml
3441bb1c988fac320d7f436b2c06b88899a6b121
...
...
@@ -10,10 +10,10 @@
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
-
Delays program execution for the given number of micro seconds.
16
+
Delays program execution for the given number of microseconds.
17
17
</para>
18
18
</refsect1>
19
19

...
...
@@ -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
-
Halt time in micro seconds. A micro second is one millionth of a
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>
...
...
@@ -41,30 +53,6 @@
41
53
</para>
42
54
</refsect1>
43
55

44
-
<refsect1 role="changelog">
45
-
&reftitle.changelog;
46
-
<para>
47
-
<informaltable>
48
-
<tgroup cols="2">
49
-
<thead>
50
-
<row>
51
-
<entry>&Version;</entry>
52
-
<entry>&Description;</entry>
53
-
</row>
54
-
</thead>
55
-
<tbody>
56
-
<row>
57
-
<entry>5.0.0</entry>
58
-
<entry>
59
-
This function now works on Windows systems.
60
-
</entry>
61
-
</row>
62
-
</tbody>
63
-
</tgroup>
64
-
</informaltable>
65
-
</para>
66
-
</refsect1>
67
-

68
56
<refsect1 role="examples">
69
57
&reftitle.examples;
70
58
<para>
...
...
@@ -75,13 +63,19 @@
75
63
<?php
76
64

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

80
-
// wait for 2 seconds
81
-
usleep(2000000);
68
+
// wait for 2 milliseconds
69
+
usleep(2000);
82
70

83
71
// back!
84
-
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";
85
79

86
80
?>
87
81
]]>
...
...
@@ -89,8 +83,9 @@ echo date('h:i:s') . "\n";
89
83
&example.outputs;
90
84
<screen>
91
85
<![CDATA[
92
-
11:13:28
93
-
11:13:30
86
+
11:13:28.005
87
+
11:13:28.007
88
+
11:13:28.037
94
89
]]>
95
90
</screen>
96
91
</example>
...
...
@@ -110,7 +105,6 @@ echo date('h:i:s') . "\n";
110
105
</refsect1>
111
106

112
107
</refentry>
113
-

114
108
<!-- Keep this comment at the end of the file
115
109
Local variables:
116
110
mode: sgml
117
111