summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/watchdog.h
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2016-07-08 16:47:06 +1000
committer Vas Crabb <vas@vastheman.com>2016-07-08 16:47:06 +1000
commit13d8279e496b0fd21aadfbaa354f4a430e9f2c70 (patch)
treedbc7136c66c43461b7dfb24bc451ba1ed5d76208 /src/osd/watchdog.h
parentc0755dd46f34fc42812b0cdbc5f37b8af8fb97c4 (diff)
MT6284 flush stdout/stderr before killing process
Diffstat (limited to 'src/osd/watchdog.h')
-rw-r--r--src/osd/watchdog.h36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/osd/watchdog.h b/src/osd/watchdog.h
index 77cf3c77c7c..0076bc42c37 100644
--- a/src/osd/watchdog.h
+++ b/src/osd/watchdog.h
@@ -1,7 +1,9 @@
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert, R. Belmont
-#ifndef _watchdog_h_
-#define _watchdog_h_
+#ifndef MAME_OSD_WATCHDOG_H
+#define MAME_OSD_WATCHDOG_H
+#pragma once
+
//============================================================
//
// watchdog.h - watchdog handling
@@ -11,26 +13,34 @@
//============================================================
#include "osdsync.h"
+
#include <atomic>
+#include <cstdint>
+#include <memory>
#include <thread>
+
class osd_watchdog
{
public:
- osd_watchdog(void);
- ~osd_watchdog(void);
-
- void reset() { m_event.set(); }
+ osd_watchdog();
+ ~osd_watchdog();
- osd_event & event(void) { return m_event; }
- INT32 do_exit(void) const { return m_do_exit; }
osd_ticks_t getTimeout(void) const { return m_timeout; }
void setTimeout(int timeout);
+
+ void reset() { m_event.set(); }
+
private:
- osd_event m_event;
- std::thread* m_thread;
- std::atomic<INT32> m_do_exit;
+ static void *watchdog_thread(void *param);
+
+ void clear_event() { m_event.reset(); }
+ bool wait() { return m_event.wait(getTimeout()); }
+ bool do_exit(void) const { return m_do_exit != 0; }
- osd_ticks_t m_timeout;
+ osd_ticks_t m_timeout;
+ osd_event m_event;
+ std::atomic<std::int32_t> m_do_exit;
+ std::unique_ptr<std::thread> m_thread;
};
-#endif
+#endif // MAME_OSD_WATCHDOG_H