[System] Process.WaitForExit now triggers event Exited.
[mono.git] / mono / utils / mono-time.h
1 #ifndef __UTILS_MONO_TIME_H__
2 #define __UTILS_MONO_TIME_H__
3
4 #include <mono/utils/mono-compiler.h>
5 #include <glib.h>
6
7 /* Returns the number of milliseconds from boot time: this should be monotonic */
8 guint32 mono_msec_ticks      (void);
9
10 /* Returns the number of 100ns ticks from unspecified time: this should be monotonic */
11 gint64  mono_100ns_ticks     (void);
12
13 /* Returns the number of 100ns ticks since 1/1/1, UTC timezone */
14 gint64  mono_100ns_datetime  (void);
15
16 /* Stopwatch class for internal runtime use */
17 typedef struct {
18         gint64 start, stop;
19 } MonoStopwatch;
20
21 static inline void
22 mono_stopwatch_start (MonoStopwatch *w)
23 {
24         w->start = mono_100ns_ticks ();
25         w->stop = 0;
26 }
27
28 static inline void
29 mono_stopwatch_stop (MonoStopwatch *w)
30 {
31         w->stop = mono_100ns_ticks ();
32 }
33
34 static inline guint64
35 mono_stopwatch_elapsed (MonoStopwatch *w)
36 {
37         return (w->stop - w->start) / 10;
38 }
39
40 static inline guint64
41 mono_stopwatch_elapsed_ms (MonoStopwatch *w)
42 {
43         return (mono_stopwatch_elapsed (w) + 500) / 1000;
44 }
45
46 #endif /* __UTILS_MONO_TIME_H__ */
47