Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
Sonde::anonymous_namespace{qmltools.cpp}::Watchdog Class Reference

Interrupts engine's JavaScript if it is still running after ms milliseconds. More...

Public Member Functions

 Watchdog (QJSEngine *engine, int ms)
 Starts watching.
 ~Watchdog ()
 Stops watching, and clears the interruption so the engine works again.
bool fired ()
 Whether the time ran out (valid once the evaluation returned).

Private Attributes

QJSEngine * m_engine
 Engine to interrupt.
std::mutex m_mutex
 Guards m_finished and m_fired.
std::condition_variable m_done
 Signals that the evaluation returned.
bool m_finished = false
 Set when the evaluation returned.
bool m_fired = false
 Set when the engine was interrupted.
std::thread m_thread
 The watching thread.

Detailed Description

Interrupts engine's JavaScript if it is still running after ms milliseconds.

QJSEngine::setInterrupted() is meant to be called from another thread, which is the only way to stop a loop that never returns to the event loop.


The documentation for this class was generated from the following file: