@@ -5945,6 +5945,37 @@ class V8_EXPORT RegExp : public Object {
5945
5945
static void CheckCast (Value* obj);
5946
5946
};
5947
5947
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
+
5948
5979
/* *
5949
5980
* A JavaScript value that wraps a C++ void*. This type of value is mainly used
5950
5981
* to associate C++ data structures with JavaScript objects.
@@ -7197,6 +7228,20 @@ typedef void (*AddCrashKeyCallback)(CrashKeyId id, const std::string& value);
7197
7228
typedef void (*BeforeCallEnteredCallback)(Isolate*);
7198
7229
typedef void (*CallCompletedCallback)(Isolate*);
7199
7230
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
+
7200
7245
/* *
7201
7246
* HostImportModuleDynamicallyCallback is called when we require the
7202
7247
* embedder to load a module. This is used as part of the dynamic
@@ -8536,6 +8581,17 @@ class V8_EXPORT Isolate {
8536
8581
void SetAbortOnUncaughtExceptionCallback (
8537
8582
AbortOnUncaughtExceptionCallback callback);
8538
8583
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
+
8539
8595
/* *
8540
8596
* This specifies the callback called by the upcoming dynamic
8541
8597
* import() language feature to load modules.
0 commit comments