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

Side by Side Diff: vm/dart_api_impl_test.cc

Issue 10450016: Add a callback to inform embedders when an isolate is being shut down. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/isolate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/utils.h" 7 #include "platform/utils.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 4689 matching lines...) Expand 10 before | Expand all | Expand 10 after
4700 MonitorLocker ml(sync); 4700 MonitorLocker ml(sync);
4701 // Wait for our isolate to finish. 4701 // Wait for our isolate to finish.
4702 while (shared_isolate != NULL) { 4702 while (shared_isolate != NULL) {
4703 ml.Wait(); 4703 ml.Wait();
4704 } 4704 }
4705 } 4705 }
4706 4706
4707 // We should have received the expected number of interrupts. 4707 // We should have received the expected number of interrupts.
4708 EXPECT_EQ(kInterruptCount, interrupt_count); 4708 EXPECT_EQ(kInterruptCount, interrupt_count);
4709 4709
4710 // Give the spawned thread enough time to properly exit.
4711 Isolate::SetInterruptCallback(saved); 4710 Isolate::SetInterruptCallback(saved);
4712 } 4711 }
4713 4712
4713 static void* saved_callback_data;
4714 static void IsolateShutdownTestCallback(void* callback_data) {
4715 saved_callback_data = callback_data;
4716 }
4717
4718 UNIT_TEST_CASE(IsolateShutdown) {
4719 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback();
4720 Isolate::SetShutdownCallback(IsolateShutdownTestCallback);
4721
4722 saved_callback_data = NULL;
4723
4724 void* my_data = reinterpret_cast<void*>(12345);
4725
4726 // Create an isolate.
4727 char* err;
4728 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, my_data, &err);
4729 if (isolate == NULL) {
4730 OS::Print("Creation of isolate failed '%s'\n", err);
4731 free(err);
4732 }
4733 EXPECT(isolate != NULL);
4734
4735 // The shutdown callback has not been called.
4736 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data));
4737
4738 // Shutdown the isolate.
4739 Dart_ShutdownIsolate();
4740
4741 // The shutdown callback has been called.
4742 EXPECT_EQ(12345, reinterpret_cast<intptr_t>(saved_callback_data));
4743
4744 Isolate::SetShutdownCallback(saved);
4745 }
4714 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 4746 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
4715 4747
4716 } // namespace dart 4748 } // namespace dart
OLDNEW
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698