Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Side by Side Diff: runtime/vm/dart_api_state.cc

Issue 2084193003: Reapply "Background finalization." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: test with monitors Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "vm/dart_api_state.h"
6
7 #include "platform/assert.h"
8 #include "platform/utils.h"
9 #include "vm/heap.h"
10 #include "vm/isolate.h"
11 #include "vm/lockers.h"
12 #include "vm/thread.h"
13 #include "vm/timeline.h"
14
15 namespace dart {
16
17 BackgroundFinalizer::BackgroundFinalizer(Isolate* isolate,
18 FinalizationQueue* queue) :
19 isolate_(isolate),
20 queue_(queue) {
21 MonitorLocker ml(isolate->heap()->finalization_tasks_lock());
22 isolate->heap()->set_finalization_tasks(
23 isolate->heap()->finalization_tasks() + 1);
24 ml.Notify();
25 }
26
27
28 void BackgroundFinalizer::Run() {
29 {
siva 2016/06/22 22:55:31 You can avoid the issues with entering the isolate
rmacnak 2016/06/22 23:13:48 Done.
30 TIMELINE_FUNCTION_GC_DURATION(Thread::Current(),
31 "BackgroundFinalization");
32
33 for (intptr_t i = 0; i < queue_->length(); i++) {
34 FinalizablePersistentHandle* handle = (*queue_)[i];
35 FinalizablePersistentHandle::Finalize(isolate_, handle);
36 }
37 delete queue_;
38 }
39
40 {
41 Heap* heap = isolate_->heap();
42 MonitorLocker ml(heap->finalization_tasks_lock());
43 heap->set_finalization_tasks(heap->finalization_tasks() - 1);
44 ml.Notify();
45 }
46 }
47
48 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698