Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
thread_interrupter.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_THREAD_INTERRUPTER_H_
6#define RUNTIME_VM_THREAD_INTERRUPTER_H_
7
8#include "vm/allocation.h"
9#include "vm/os_thread.h"
10#include "vm/signal_handler.h"
11#include "vm/thread.h"
12
13namespace dart {
14
16 uintptr_t pc;
17 uintptr_t csp;
18 uintptr_t dsp;
19 uintptr_t fp;
20 uintptr_t lr;
21};
22
24 public:
25 static void Init();
26
27 static void Startup();
28 static void Cleanup();
29
30 // Delay between interrupts.
31 static void SetInterruptPeriod(intptr_t period);
32
33 // Wake up the thread interrupter thread.
34 static void WakeUp();
35
36 // Interrupt a thread.
37 static void InterruptThread(OSThread* thread);
38
39 // Prepare current thread for handling interrupts. Returns
40 // opaque pointer to the allocated state (if any).
41 static void* PrepareCurrentThread();
42
43 // Cleanup any state which was created by |PrepareCurrentThread|.
44 static void CleanupCurrentThreadState(void* state);
45
46 private:
47 static constexpr intptr_t kMaxThreads = 4096;
48 static bool initialized_;
49 static bool shutdown_;
50 static bool thread_running_;
51 static bool woken_up_;
52 static ThreadJoinId interrupter_thread_id_;
53 static Monitor* monitor_;
54 static intptr_t interrupt_period_;
55 static intptr_t current_wait_time_;
56
57 static bool InDeepSleep() {
58 return current_wait_time_ == Monitor::kNoTimeout;
59 }
60
61 static void ThreadMain(uword parameters);
62
63 static void InstallSignalHandler();
64
65 static void RemoveSignalHandler();
66
68};
69
70} // namespace dart
71
72#endif // RUNTIME_VM_THREAD_INTERRUPTER_H_
static constexpr int64_t kNoTimeout
Definition os_thread.h:360
friend class ThreadInterrupterVisitIsolates
static void CleanupCurrentThreadState(void *state)
static void SetInterruptPeriod(intptr_t period)
static void * PrepareCurrentThread()
static void InterruptThread(OSThread *thread)
AtkStateType state
pthread_t ThreadJoinId
uintptr_t uword
Definition globals.h:501