Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
thread_registry.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_THREAD_REGISTRY_H_
6#define RUNTIME_VM_THREAD_REGISTRY_H_
7
8#include "vm/globals.h"
9#include "vm/growable_array.h"
10#include "vm/isolate.h"
11#include "vm/lockers.h"
12#include "vm/stack_frame.h"
13#include "vm/thread.h"
14
15namespace dart {
16
17#ifndef PRODUCT
18class JSONStream;
19class JSONArray;
20#endif
21
22// Unordered collection of threads relating to a particular isolate group.
24 public:
26 : threads_lock_(),
27 active_list_(nullptr),
28 free_list_(nullptr),
29 active_isolates_count_(0) {}
31
32 void VisitObjectPointers(IsolateGroup* isolate_group_of_interest,
33 ObjectPointerVisitor* visitor,
34 ValidationPolicy validate_frames);
35
36 void ForEachThread(std::function<void(Thread* thread)> callback);
40 void FlushMarkingStacks();
41
42 // Concurrent-approximate number of active isolates in the active_list
43 intptr_t active_isolates_count() { return active_isolates_count_.load(); }
44
45 Monitor* threads_lock() const { return &threads_lock_; }
46
47#ifndef PRODUCT
48 void PrintJSON(JSONStream* stream) const;
49#endif
50
51 private:
52 Thread* active_list() const { return active_list_; }
53
54 Thread* GetFreeThreadLocked(bool is_vm_isolate);
55 void ReturnThreadLocked(Thread* thread);
56 void AddToActiveListLocked(Thread* thread);
57 void RemoveFromActiveListLocked(Thread* thread);
58 Thread* GetFromFreelistLocked(bool is_vm_isolate);
59 void ReturnToFreelistLocked(Thread* thread);
60
61 // This monitor protects the threads list for an isolate, it is used whenever
62 // we need to iterate over threads (both active and free) in an isolate.
63 mutable Monitor threads_lock_;
64 Thread* active_list_; // List of active threads in the isolate.
65 Thread* free_list_; // Free list of Thread objects that can be reused.
66 RelaxedAtomic<intptr_t> active_isolates_count_;
67
68 friend class Thread;
69 friend class SafepointHandler;
71};
72
73} // namespace dart
74
75#endif // RUNTIME_VM_THREAD_REGISTRY_H_
T load(std::memory_order order=std::memory_order_relaxed) const
Definition atomic.h:21
intptr_t active_isolates_count()
void VisitObjectPointers(IsolateGroup *isolate_group_of_interest, ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
void PrintJSON(JSONStream *stream) const
Monitor * threads_lock() const
void ForEachThread(std::function< void(Thread *thread)> callback)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
ValidationPolicy
Definition thread.h:271
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581