[vm] Isolate ownership API

go/dart-isolate-ownership-api

Change-Id: Ia778a916de3fecec9f0aa1a5c8bc9fd7dd421267
Bug: https://github.com/dart-lang/native/issues/1908
TEST=runtime/vm/dart_api_impl_test.cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
This commit is contained in:
Liam Appelbe
2025-02-11 20:09:11 -08:00
committed by Commit Queue
parent b1e10bff4f
commit cb02b8726a
11 changed files with 225 additions and 21 deletions
+18 -2
View File
@@ -1707,8 +1707,6 @@ DART_EXPORT DART_API_WARN_UNUSED_RESULT bool Dart_RunLoopAsync(
Dart_Port on_exit_port,
char** error);
/* TODO(turnidge): Should this be removed from the public api? */
/**
* Gets the main port id for the current isolate.
*/
@@ -1779,6 +1777,24 @@ DART_EXPORT Dart_Handle Dart_SendPortGetId(Dart_Handle port,
*/
DART_EXPORT Dart_Handle Dart_SendPortGetIdEx(Dart_Handle port,
Dart_PortEx* portex_id);
/**
* Sets the owner thread of the current isolate to be the current thread.
*
* Requires there to be a current isolate, and that the isolate is unowned.
*/
DART_EXPORT void Dart_SetCurrentThreadOwnsIsolate(void);
/**
* Returns whether the current thread owns the isolate that owns the given port.
*
* The port can be the isolate's main port, or any other port owned by the
* isolate.
*
* \param port_id The port to be checked.
*/
DART_EXPORT bool Dart_GetCurrentThreadOwnsIsolate(Dart_Port port);
/*
* ======
* Scopes
+2
View File
@@ -96,6 +96,7 @@ typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id,
F(Dart_ExitIsolate, void, (void)) \
F(Dart_EnterIsolate, void, (Dart_Isolate)) \
/* Dart_Port */ \
F(Dart_GetMainPortId, Dart_Port, (void)) \
F(Dart_Post, bool, (Dart_Port_DL port_id, Dart_Handle object)) \
F(Dart_NewSendPort, Dart_Handle, (Dart_Port_DL port_id)) \
F(Dart_NewSendPortEx, Dart_Handle, (Dart_PortEx_DL portex_id)) \
@@ -103,6 +104,7 @@ typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id,
(Dart_Handle port, Dart_Port_DL * port_id)) \
F(Dart_SendPortGetIdEx, Dart_Handle, \
(Dart_Handle port, Dart_PortEx_DL * portex_id)) \
F(Dart_GetCurrentThreadOwnsIsolate, bool, (Dart_Port)) \
/* Scopes */ \
F(Dart_EnterScope, void, (void)) \
F(Dart_ExitScope, void, (void)) \
+1 -1
View File
@@ -11,6 +11,6 @@
// On backwards compatible changes the minor version is increased.
// The versioning covers the symbols exposed in dart_api_dl.h
#define DART_API_DL_MAJOR_VERSION 2
#define DART_API_DL_MINOR_VERSION 5
#define DART_API_DL_MINOR_VERSION 6
#endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */