@@ -5945,6 +5945,37 @@ class V8_EXPORT RegExp : public Object {
59455945 static void CheckCast (Value* obj);
59465946};
59475947
5948+ /* *
5949+ * An instance of the built-in FinalizationRegistry constructor.
5950+ *
5951+ * The C++ name is FinalizationGroup for backwards compatibility. This API is
5952+ * experimental and deprecated.
5953+ */
5954+ class V8_EXPORT FinalizationGroup : public Object {
5955+ public:
5956+ /* *
5957+ * Runs the cleanup callback of the given FinalizationRegistry.
5958+ *
5959+ * V8 will inform the embedder that there are finalizer callbacks be
5960+ * called through HostCleanupFinalizationGroupCallback.
5961+ *
5962+ * HostCleanupFinalizationGroupCallback should schedule a task to
5963+ * call FinalizationGroup::Cleanup() at some point in the
5964+ * future. It's the embedders responsiblity to make this call at a
5965+ * time which does not interrupt synchronous ECMAScript code
5966+ * execution.
5967+ *
5968+ * If the result is Nothing<bool> then an exception has
5969+ * occurred. Otherwise the result is |true| if the cleanup callback
5970+ * was called successfully. The result is never |false|.
5971+ */
5972+ V8_DEPRECATED (
5973+ " FinalizationGroup cleanup is automatic if "
5974+ " HostCleanupFinalizationGroupCallback is not set" )
5975+ static V8_WARN_UNUSED_RESULT Maybe<bool > Cleanup (
5976+ Local<FinalizationGroup> finalization_group);
5977+ };
5978+
59485979/* *
59495980 * A JavaScript value that wraps a C++ void*. This type of value is mainly used
59505981 * to associate C++ data structures with JavaScript objects.
@@ -7197,6 +7228,20 @@ typedef void (*AddCrashKeyCallback)(CrashKeyId id, const std::string& value);
71977228typedef void (*BeforeCallEnteredCallback)(Isolate*);
71987229typedef void (*CallCompletedCallback)(Isolate*);
71997230
7231+ /* *
7232+ * HostCleanupFinalizationGroupCallback is called when we require the
7233+ * embedder to enqueue a task that would call
7234+ * FinalizationGroup::Cleanup().
7235+ *
7236+ * The FinalizationGroup is the one for which the embedder needs to
7237+ * call FinalizationGroup::Cleanup() on.
7238+ *
7239+ * The context provided is the one in which the FinalizationGroup was
7240+ * created in.
7241+ */
7242+ typedef void (*HostCleanupFinalizationGroupCallback)(
7243+ Local<Context> context, Local<FinalizationGroup> fg);
7244+
72007245/* *
72017246 * HostImportModuleDynamicallyCallback is called when we require the
72027247 * embedder to load a module. This is used as part of the dynamic
@@ -8536,6 +8581,17 @@ class V8_EXPORT Isolate {
85368581 void SetAbortOnUncaughtExceptionCallback (
85378582 AbortOnUncaughtExceptionCallback callback);
85388583
8584+ /* *
8585+ * This specifies the callback to be called when FinalizationRegistries
8586+ * are ready to be cleaned up and require FinalizationGroup::Cleanup()
8587+ * to be called in a future task.
8588+ */
8589+ V8_DEPRECATED (
8590+ " FinalizationRegistry cleanup is automatic if "
8591+ " HostCleanupFinalizationGroupCallback is not set" )
8592+ void SetHostCleanupFinalizationGroupCallback (
8593+ HostCleanupFinalizationGroupCallback callback);
8594+
85398595 /* *
85408596 * This specifies the callback called by the upcoming dynamic
85418597 * import() language feature to load modules.
0 commit comments