OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1605 | 1605 |
1606 | 1606 |
1607 DART_EXPORT Dart_Handle Dart_RunLoop() { | 1607 DART_EXPORT Dart_Handle Dart_RunLoop() { |
1608 Thread* T = Thread::Current(); | 1608 Thread* T = Thread::Current(); |
1609 Isolate* I = T->isolate(); | 1609 Isolate* I = T->isolate(); |
1610 CHECK_API_SCOPE(T); | 1610 CHECK_API_SCOPE(T); |
1611 CHECK_CALLBACK_STATE(T); | 1611 CHECK_CALLBACK_STATE(T); |
1612 API_TIMELINE_BEGIN_END; | 1612 API_TIMELINE_BEGIN_END; |
1613 // The message handler run loop does not expect to have a current isolate | 1613 // The message handler run loop does not expect to have a current isolate |
1614 // so we exit the isolate here and enter it again after the runloop is done. | 1614 // so we exit the isolate here and enter it again after the runloop is done. |
1615 ::Dart_ExitIsolate(); | 1615 ::Dart_ExitIsolate(); |
Ivan Posva
2016/03/09 08:27:18
To avoid my question from below we should structur
srdjan
2016/03/09 19:10:15
Adapted to the lifetime of stack objets:
Isolat
| |
1616 { | 1616 { |
1617 Monitor monitor; | 1617 Monitor monitor; |
1618 MonitorLocker ml(&monitor); | 1618 MonitorLocker ml(&monitor); |
1619 RunLoopData data; | 1619 RunLoopData data; |
1620 data.monitor = &monitor; | 1620 data.monitor = &monitor; |
1621 data.done = false; | 1621 data.done = false; |
1622 I->message_handler()->Run( | 1622 I->message_handler()->Run( |
1623 Dart::thread_pool(), | 1623 Dart::thread_pool(), |
1624 NULL, RunLoopDone, reinterpret_cast<uword>(&data)); | 1624 NULL, RunLoopDone, reinterpret_cast<uword>(&data)); |
1625 while (!data.done) { | 1625 while (!data.done) { |
1626 ml.Wait(); | 1626 ml.Wait(); |
1627 } | 1627 } |
1628 } | 1628 } |
1629 ::Dart_EnterIsolate(Api::CastIsolate(I)); | 1629 ::Dart_EnterIsolate(Api::CastIsolate(I)); |
1630 if (T->sticky_error() != Object::null()) { | 1630 T = Thread::Current(); |
siva
2016/03/09 07:07:51
Do we need this here since Api::NewHandle is calle
Ivan Posva
2016/03/09 08:27:18
Why is this even necessary. How can T have changed
srdjan
2016/03/09 19:10:15
Done.
srdjan
2016/03/09 19:10:15
::Dart_EnterIsolate(...) sets new Thread::Current
| |
1631 Dart_Handle error = Api::NewHandle(T, T->sticky_error()); | 1631 if (I->object_store()->sticky_error() != Object::null()) { |
1632 T->clear_sticky_error(); | 1632 Dart_Handle error = Api::NewHandle(T, I->object_store()->sticky_error()); |
1633 I->object_store()->clear_sticky_error(); | |
1633 return error; | 1634 return error; |
1634 } | 1635 } |
1635 if (FLAG_print_class_table) { | 1636 if (FLAG_print_class_table) { |
1636 HANDLESCOPE(T); | 1637 HANDLESCOPE(T); |
1637 I->class_table()->Print(); | 1638 I->class_table()->Print(); |
1638 } | 1639 } |
1639 return Api::Success(); | 1640 return Api::Success(); |
1640 } | 1641 } |
1641 | 1642 |
1642 | 1643 |
(...skipping 4551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6194 return Api::Success(); | 6195 return Api::Success(); |
6195 } | 6196 } |
6196 #endif // DART_PRECOMPILER | 6197 #endif // DART_PRECOMPILER |
6197 | 6198 |
6198 | 6199 |
6199 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { | 6200 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { |
6200 return Dart::IsRunningPrecompiledCode(); | 6201 return Dart::IsRunningPrecompiledCode(); |
6201 } | 6202 } |
6202 | 6203 |
6203 } // namespace dart | 6204 } // namespace dart |
OLD | NEW |