Merge System into Support.
[oota-llvm.git] / include / llvm / Support / Alarm.h
1 //===- llvm/System/Alarm.h - Alarm Generation support  ----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides an operating system independent interface to alarm(2)
11 // type functionality. The Alarm class allows a one-shot alarm to be set up
12 // at some number of seconds in the future. When the alarm triggers, a method
13 // is called to process the event
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_SYSTEM_ALARM_H
18 #define LLVM_SYSTEM_ALARM_H
19
20 namespace llvm {
21 namespace sys {
22
23   /// This function registers an alarm to trigger some number of \p seconds in
24   /// the future. When that time arrives, the AlarmStatus function will begin
25   /// to return 1 instead of 0. The user must poll the status of the alarm by
26   /// making occasional calls to AlarmStatus. If the user sends an interrupt
27   /// signal, AlarmStatus will begin returning -1, even if the alarm event
28   /// occurred.
29   /// @returns nothing
30   void SetupAlarm(
31     unsigned seconds ///< Number of seconds in future when alarm arrives
32   );
33
34   /// This function terminates the alarm previously set up
35   /// @returns nothing
36   void TerminateAlarm();
37
38   /// This function acquires the status of the alarm.
39   /// @returns -1=cancelled, 0=untriggered, 1=triggered
40   int AlarmStatus();
41
42   /// Sleep for n seconds. Warning: mixing calls to Sleep() and other *Alarm
43   /// calls may be a bad idea on some platforms (source: Linux man page).
44   /// @returns nothing.
45   void Sleep(unsigned n);
46
47
48 } // End sys namespace
49 } // End llvm namespace
50
51 #endif