// vim: set ts=8 sts=2 sw=2 tw=99 et: // // This file is part of SourcePawn. // // SourcePawn is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // SourcePawn is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with SourcePawn. If not, see . #ifndef _include_sourcepawn_watchdog_timer_posix_h_ #define _include_sourcepawn_watchdog_timer_posix_h_ #include #include #include namespace sp { class Environment; typedef bool (*WatchdogCallback)(); class WatchdogTimer : public ke::IRunnable { public: WatchdogTimer(Environment *env); ~WatchdogTimer(); bool Initialize(size_t timeout_ms); void Shutdown(); // Called from main thread. bool NotifyTimeoutReceived(); bool HandleInterrupt(); private: // Watchdog thread. void Run(); private: Environment *env_; bool terminate_; size_t timeout_ms_; ke::ThreadId mainthread_; ke::AutoPtr thread_; ke::ConditionVariable cv_; // Accessed only on the watchdog thread. uintptr_t last_frame_id_; bool second_timeout_; // Accessed only on the main thread. bool timedout_; }; } // namespace sp #endif // _include_sourcepawn_watchdog_timer_posix_h_