Bug 1874684 - Part 31: Correctly reject invalid durations in some RoundDuration calls...
[gecko.git] / js / public / Interrupt.h
blob3e7ead7b286d4d1e61a8c6305954ebd74aff120d
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef js_Interrupt_h
7 #define js_Interrupt_h
9 #include "jstypes.h"
11 struct JS_PUBLIC_API JSContext;
13 using JSInterruptCallback = bool (*)(JSContext*);
15 extern JS_PUBLIC_API bool JS_CheckForInterrupt(JSContext* cx);
18 * These functions allow setting an interrupt callback that will be called
19 * from the JS thread some time after any thread triggered the callback using
20 * JS_RequestInterruptCallback(cx).
22 * To schedule the GC and for other activities the engine internally triggers
23 * interrupt callbacks. The embedding should thus not rely on callbacks being
24 * triggered through the external API only.
26 * Important note: Additional callbacks can occur inside the callback handler
27 * if it re-enters the JS engine. The embedding must ensure that the callback
28 * is disconnected before attempting such re-entry.
30 extern JS_PUBLIC_API bool JS_AddInterruptCallback(JSContext* cx,
31 JSInterruptCallback callback);
33 extern JS_PUBLIC_API bool JS_DisableInterruptCallback(JSContext* cx);
35 extern JS_PUBLIC_API void JS_ResetInterruptCallback(JSContext* cx, bool enable);
37 extern JS_PUBLIC_API void JS_RequestInterruptCallback(JSContext* cx);
39 extern JS_PUBLIC_API void JS_RequestInterruptCallbackCanWait(JSContext* cx);
41 #endif // js_Interrupt_h