src: deduplicate CHECK_EQ/CHECK_NE macros
[platform/upstream/nodejs.git] / src / node_watchdog.h
1 // Copyright Joyent, Inc. and other Node contributors.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to permit
8 // persons to whom the Software is furnished to do so, subject to the
9 // following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 #ifndef SRC_NODE_WATCHDOG_H_
23 #define SRC_NODE_WATCHDOG_H_
24
25 #include "v8.h"
26 #include "uv.h"
27
28 namespace node {
29
30 class Watchdog {
31  public:
32   explicit Watchdog(uint64_t ms);
33   ~Watchdog();
34
35   void Dispose();
36
37  private:
38   void Destroy();
39
40   static void Run(void* arg);
41   static void Async(uv_async_t* async, int status);
42   static void Timer(uv_timer_t* timer, int status);
43
44   uv_thread_t thread_;
45   uv_loop_t* loop_;
46   uv_async_t async_;
47   uv_timer_t timer_;
48   bool destroyed_;
49 };
50
51 }  // namespace node
52
53 #endif  // SRC_NODE_WATCHDOG_H_