OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 #ifndef RUNTIME_VM_THREAD_REGISTRY_H_ | 5 #ifndef RUNTIME_VM_THREAD_REGISTRY_H_ |
6 #define RUNTIME_VM_THREAD_REGISTRY_H_ | 6 #define RUNTIME_VM_THREAD_REGISTRY_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 void ReturnThreadLocked(bool is_mutator, Thread* thread); | 36 void ReturnThreadLocked(bool is_mutator, Thread* thread); |
37 void AddToActiveListLocked(Thread* thread); | 37 void AddToActiveListLocked(Thread* thread); |
38 void RemoveFromActiveListLocked(Thread* thread); | 38 void RemoveFromActiveListLocked(Thread* thread); |
39 Thread* GetFromFreelistLocked(Isolate* isolate); | 39 Thread* GetFromFreelistLocked(Isolate* isolate); |
40 void ReturnToFreelistLocked(Thread* thread); | 40 void ReturnToFreelistLocked(Thread* thread); |
41 | 41 |
42 // This monitor protects the threads list for an isolate, it is used whenever | 42 // This monitor protects the threads list for an isolate, it is used whenever |
43 // we need to iterate over threads (both active and free) in an isolate. | 43 // we need to iterate over threads (both active and free) in an isolate. |
44 Monitor* threads_lock_; | 44 Monitor* threads_lock_; |
45 Thread* active_list_; // List of active threads in the isolate. | 45 Thread* active_list_; // List of active threads in the isolate. |
46 Thread* free_list_; // Free list of Thread objects that can be reused. | 46 Thread* free_list_; // Free list of Thread objects that can be reused. |
47 | 47 |
48 // TODO(asiva): Currently we treat a mutator thread as a special thread | 48 // TODO(asiva): Currently we treat a mutator thread as a special thread |
49 // and always schedule execution of Dart code on the same mutator thread | 49 // and always schedule execution of Dart code on the same mutator thread |
50 // object. The ApiLocalScope has been made thread specific but we still | 50 // object. The ApiLocalScope has been made thread specific but we still |
51 // have scenarios where we do a temporary exit of an Isolate with live | 51 // have scenarios where we do a temporary exit of an Isolate with live |
52 // zones/handles in the API scope : | 52 // zones/handles in the API scope : |
53 // - Dart_RunLoop() | 53 // - Dart_RunLoop() |
54 // - IsolateSaver in Dart_NewNativePort | 54 // - IsolateSaver in Dart_NewNativePort |
55 // - Isolate spawn (function/uri) under FLAG_i_like_slow_isolate_spawn | 55 // - Isolate spawn (function/uri) under FLAG_i_like_slow_isolate_spawn |
56 // We probably need a mechanism to return to the specific thread only | 56 // We probably need a mechanism to return to the specific thread only |
57 // for these specific cases. We should also determine if the embedder | 57 // for these specific cases. We should also determine if the embedder |
58 // should allow exiting an isolate with live state in zones/handles in | 58 // should allow exiting an isolate with live state in zones/handles in |
59 // which case a new API for returning to the specific thread needs to be | 59 // which case a new API for returning to the specific thread needs to be |
60 // added. | 60 // added. |
61 Thread* mutator_thread_; | 61 Thread* mutator_thread_; |
62 | 62 |
63 friend class Isolate; | 63 friend class Isolate; |
64 friend class SafepointHandler; | 64 friend class SafepointHandler; |
65 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); | 65 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); |
66 }; | 66 }; |
67 | 67 |
68 } // namespace dart | 68 } // namespace dart |
69 | 69 |
70 #endif // RUNTIME_VM_THREAD_REGISTRY_H_ | 70 #endif // RUNTIME_VM_THREAD_REGISTRY_H_ |
OLD | NEW |