@@ -255,6 +255,25 @@ struct Script
255255 // / @return A wrapper managing the program-hosted objects. Can be moved.
256256 template <typename T> GuestObjects<T> guest_alloc (size_t n = 1 );
257257
258+ // / @brief Set the waiting state of the script.
259+ // / This can be used to signal that the script is waiting in an event loop,
260+ // / such as waiting for a frame to complete, or waiting for an event to occur.
261+ // / @param state A user-defined state value, such as 0 for no wait, 1 for waiting for a frame, etc.
262+ void setWaitingState (uint8_t state) noexcept
263+ {
264+ m_waiting_state = state;
265+ }
266+
267+ // / @brief Get the current waiting state of the script.
268+ // / This can be used to check if the script is waiting in an event loop,
269+ // / such as waiting for a frame to complete, or waiting for an event to occur.
270+ // / @return The current waiting state value, such as 0 for no wait, 1 for waiting for a frame, etc.
271+ // / @note The waiting state is user-defined and can be any value.
272+ uint8_t getWaitingState () const noexcept
273+ {
274+ return m_waiting_state;
275+ }
276+
258277 // / @brief Start debugging with GDB right now. Only works on Linux.
259278 // / @param message Message to print inside GDB.
260279 // / @param one_up Always go one stack frame up? This can be used to leave a wrapper function.
@@ -322,6 +341,7 @@ struct Script
322341 bool m_stdout = true ;
323342 bool m_last_newline = true ;
324343 int m_budget_overruns = 0 ;
344+ uint8_t m_waiting_state = 0 ;
325345 Script* m_remote_script = nullptr ;
326346 // / @brief Functions accessible when remote access is *strict*
327347 std::unordered_set<gaddr_t > m_remote_access;
0 commit comments