dart-sdk/runtime/include
Martin Kustermann bf4280ff75 [vm/concurrency] Add Dart_CreateLightweightIsolate/Dart_RunLoopAsync APIs
Dart_CreateLightweightIsolate API:

  This API can be used by embedders to create a lightweight isolate
  (inside an existing isolate group).

  It is the analogous to Dart_CreateIsolateGroup - though taking a
  parent isolate as parameter (inside whose IG we create a new isolate)
  instead of taking kernel/snapshot data.

  Right now this API works on AOT and returns an error in JIT, both cases
  are covered by the test.

Dart_RunLoopAsync:

  The API can be used by embedders to transfer ownership of an isolate to
  the VM, which will take care of running the message handling loop and
  shuts the isolate down once the last receive port has been closed.

  It does allow listening to error/exit events generated by the message
  loop implementation as well as allows setting errors-are-fatal,
  effectively the same event-loop related parameters from the
  `Isolate.spawn()` API, just in Dart.

  It's the embedders responsibility to first launch initial dart code
  which will take care of responding to events (i.e. directly/indirectly
  open a receive port) - otherwise the isolate cannot be talked to and
  would immediately shut down.

Since our vm/cc tests do support running in AOT, we use a hybrid
approach to test the functionality: We let a normal Dart test call a
small C wrapper using FFI, to create a lightweight isolate, run it on a
new thread and join that thread.

TEST=vm/dart{,_2}/isolates/dart_api_create_lightweight_isolate_test

Issue https://github.com/dart-lang/sdk/issues/36097
Closes https://github.com/dart-lang/sdk/issues/44088

Change-Id: Id77ba928793fdb517f6cb7e8130df98a0366ddd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170983
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-11-12 10:22:16 +00:00
..
bin Rollforward of the dart_io_api.h include change, with a fix for flutter. 2018-11-19 18:16:11 +00:00
internal [vm/ffi] Change dart_api_dl.cc to dart_api_dl.c 2020-08-10 15:11:21 +00:00
dart_api.h [vm/concurrency] Add Dart_CreateLightweightIsolate/Dart_RunLoopAsync APIs 2020-11-12 10:22:16 +00:00
dart_api_dl.c [vm] Change import paths inside runtime/include 2020-09-25 11:09:44 +00:00
dart_api_dl.h [vm] Native API: Make Dart_NewWeakPersistentHandle not auto delete 2020-11-03 10:27:44 +00:00
dart_embedder_api.h [vm] Avoid allocating Monitor/Mutex/... with global initializer, use Init()/Cleanup() functions instead 2020-03-17 08:49:52 +00:00
dart_native_api.h [vm] Native API: Make Dart_NewWeakPersistentHandle not auto delete 2020-11-03 10:27:44 +00:00
dart_tools_api.h [API] Changes Dart_GCEvent to mirror Service Protocol closer. 2020-09-09 07:25:44 +00:00
dart_version.h [vm] Native API: Make Dart_NewWeakPersistentHandle not auto delete 2020-11-03 10:27:44 +00:00