Without a service isolate callback, don't spawn a thread

The thread just exist immediately, so we should avoid the memory, etc.
churn of spawning the thread.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2982783002 .
This commit is contained in:
Zachary Anderson 2017-07-13 15:26:42 -07:00
parent be95b916dd
commit f67adeaaf7

View file

@ -327,12 +327,7 @@ class RunServiceTask : public ThreadPool::Task {
Dart_IsolateCreateCallback create_callback =
ServiceIsolate::create_callback();
// TODO(johnmccutchan): Support starting up service isolate without embedder
// provided isolate creation callback.
if (create_callback == NULL) {
ServiceIsolate::FinishedInitializing();
return;
}
ASSERT(create_callback != NULL);
Dart_IsolateFlags api_flags;
Isolate::FlagsInitialize(&api_flags);
@ -460,6 +455,10 @@ void ServiceIsolate::Run() {
// Grab the isolate create callback here to avoid race conditions with tests
// that change this after Dart_Initialize returns.
create_callback_ = Isolate::CreateCallback();
if (create_callback_ == NULL) {
ServiceIsolate::FinishedInitializing();
return;
}
Dart::thread_pool()->Run(new RunServiceTask());
}