2cdb8f7a266389f79dbf2ad54fe56fd97eb38fd1
[platform/upstream/glib.git] / docs / reference / glib / tmpl / timers.sgml
1 <!-- ##### SECTION Title ##### -->
2 Timers
3
4 <!-- ##### SECTION Short_Description ##### -->
5
6 keep track of elapsed time.
7
8 <!-- ##### SECTION Long_Description ##### -->
9 <para>
10 #GTimer records a start time, and counts microseconds elapsed since that time.
11 This is done somewhat differently on different platforms, and can be tricky to
12 get exactly right, so #GTimer provides a portable/convenient interface.
13 </para>
14
15 <!-- ##### SECTION See_Also ##### -->
16 <para>
17
18 </para>
19
20 <!-- ##### STRUCT GTimer ##### -->
21 <para>
22 Opaque datatype that records a start time. 
23 </para>
24
25
26 <!-- ##### FUNCTION g_timer_new ##### -->
27 <para>
28 Creates a new timer, and starts timing (i.e. g_timer_start() is implicitly
29 called for you).
30 </para>
31
32 @Returns: a new #GTimer.
33
34
35 <!-- ##### FUNCTION g_timer_start ##### -->
36 <para>
37 Marks a start time, so that future calls to g_timer_elapsed() will report the
38 time since g_timer_start() was called. g_timer_new() automatically marks the
39 start time, so no need to call g_timer_start() immediately after creating the
40 timer.
41 </para>
42
43 @timer: a #GTimer.
44
45
46 <!-- ##### FUNCTION g_timer_stop ##### -->
47 <para>
48 Marks an end time, so calls to g_timer_elapsed() will return the difference
49 between this end time and the start time.
50 </para>
51
52 @timer: a #GTimer.
53
54
55 <!-- ##### FUNCTION g_timer_elapsed ##### -->
56 <para>
57 If @timer has been started but not stopped, obtains the time since the timer was
58 started. If @timer has been stopped, obtains the elapsed time between the time
59 it was started and the time it was stopped. The return value is the number of
60 seconds elapsed, and the @microseconds argument allows you to get the number of
61 microseconds.
62 </para>
63
64 @timer: a #GTimer.
65 @microseconds: return location for microseconds elapsed, or %NULL.
66 @Returns: seconds elapsed.
67
68
69 <!-- ##### FUNCTION g_timer_reset ##### -->
70 <para>
71 This function is useless; it's fine to call g_timer_start() on an
72 already-started timer to reset the start time, so g_timer_reset() serves no
73 purpose.
74 </para>
75
76 @timer: a #GTimer.
77
78
79 <!-- ##### FUNCTION g_timer_destroy ##### -->
80 <para>
81 Destroys a timer, freeing associated resources.
82 </para>
83
84 @timer: a #GTimer to destroy.
85
86