Changeset 213238 in webkit for trunk/Source/JavaScriptCore/runtime/JSLock.h
- Timestamp:
- Mar 1, 2017, 12:15:08 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSLock.h
r213231 r213238 21 21 #pragma once 22 22 23 #include "PlatformThread.h" 23 24 #include <mutex> 24 #include <thread>25 25 #include <wtf/Assertions.h> 26 26 #include <wtf/Lock.h> … … 94 94 VM* vm() { return m_vm; } 95 95 96 std::thread::id ownerThread() const { return m_ownerThreadID; } 97 JS_EXPORT_PRIVATE bool currentThreadIsHoldingLock(); 96 std::optional<PlatformThread> ownerThread() const 97 { 98 if (m_hasOwnerThread) 99 return m_ownerThread; 100 return { }; 101 } 102 bool currentThreadIsHoldingLock() { return m_hasOwnerThread && m_ownerThread == currentPlatformThread(); } 98 103 99 104 void willDestroyVM(VM*); … … 127 132 128 133 Lock m_lock; 129 std::thread::id m_ownerThreadID; 134 // We cannot make m_ownerThread an optional (instead of pairing it with an explicit 135 // m_hasOwnerThread) because currentThreadIsHoldingLock() may be called from a 136 // different thread, and an optional is vulnerable to races. 137 // See https://bugs.webkit.org/show_bug.cgi?id=169042#c6 138 bool m_hasOwnerThread { false }; 139 PlatformThread m_ownerThread; 130 140 intptr_t m_lockCount; 131 141 unsigned m_lockDropDepth;
Note:
See TracChangeset
for help on using the changeset viewer.