Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
os_thread_win.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_OS_THREAD_WIN_H_
6#define RUNTIME_VM_OS_THREAD_WIN_H_
7
8#if !defined(RUNTIME_VM_OS_THREAD_H_)
9#error Do not include os_thread_win.h directly; use os_thread.h instead.
10#endif
11
12#include "platform/assert.h"
13#include "platform/globals.h"
14
15#include "vm/allocation.h"
16
17namespace dart {
18
19typedef DWORD ThreadLocalKey;
20typedef DWORD ThreadId;
21typedef HANDLE ThreadJoinId;
22
24
25class ThreadInlineImpl {
26 private:
29
30 static uword GetThreadLocal(ThreadLocalKey key) {
32 return reinterpret_cast<uword>(TlsGetValue(key));
33 }
34
35 friend class OSThread;
36 friend unsigned int __stdcall ThreadEntry(void* data_ptr);
37
40};
41
42class MutexData {
43 private:
44 MutexData() {}
45 ~MutexData() {}
46
47 SRWLOCK lock_;
48
49 friend class Mutex;
50
52 DISALLOW_COPY_AND_ASSIGN(MutexData);
53};
54
55class MonitorData {
56 private:
57 MonitorData() {}
58 ~MonitorData() {}
59
60 SRWLOCK lock_;
61 CONDITION_VARIABLE cond_;
62
63 friend class Monitor;
64
66 DISALLOW_COPY_AND_ASSIGN(MonitorData);
67};
68
69typedef void (*ThreadDestructor)(void* parameter);
70
72 public:
75
76 ThreadLocalKey key() const { return key_; }
77
78 ThreadDestructor destructor() const { return destructor_; }
79
80 private:
81 ThreadLocalKey key_;
82 ThreadDestructor destructor_;
83
84 DISALLOW_ALLOCATION();
85};
86
87template <typename T>
88class MallocGrowableArray;
89
90class ThreadLocalData : public AllStatic {
91 public:
92 static void RunDestructors();
93
94 private:
95 static void AddThreadLocal(ThreadLocalKey key, ThreadDestructor destructor);
96 static void RemoveThreadLocal(ThreadLocalKey key);
97
98 static Mutex* mutex_;
99 static MallocGrowableArray<ThreadLocalEntry>* thread_locals_;
100
101 static void Init();
102 static void Cleanup();
103
104 friend class OS;
105 friend class OSThread;
106};
107
108} // namespace dart
109
110#endif // RUNTIME_VM_OS_THREAD_WIN_H_
friend class Monitor
friend class Mutex
Definition os.h:19
friend unsigned int __stdcall ThreadEntry(void *data_ptr)
static void RunDestructors()
ThreadLocalKey key() const
ThreadLocalEntry(ThreadLocalKey key, ThreadDestructor destructor)
ThreadDestructor destructor() const
#define ASSERT(E)
pthread_t ThreadJoinId
uintptr_t uword
Definition globals.h:501
void(* ThreadDestructor)(void *parameter)
pthread_key_t ThreadLocalKey
static const ThreadLocalKey kUnsetThreadLocalKey
pthread_t ThreadId
#define DISALLOW_ALLOCATION()
Definition globals.h:604
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581
WINBASEAPI LPVOID WINAPI TlsGetValue(_In_ DWORD dwTlsIndex)
RTL_SRWLOCK SRWLOCK
#define TLS_OUT_OF_INDEXES
void * HANDLE
unsigned long DWORD