| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 RTC_DCHECK(recursion_count_ >= 0); | 81 RTC_DCHECK(recursion_count_ >= 0); |
| 82 if (!recursion_count_) | 82 if (!recursion_count_) |
| 83 thread_ = 0; | 83 thread_ = 0; |
| 84 #endif | 84 #endif |
| 85 pthread_mutex_unlock(&mutex_); | 85 pthread_mutex_unlock(&mutex_); |
| 86 #endif | 86 #endif |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool CriticalSection::CurrentThreadIsOwner() const { | 89 bool CriticalSection::CurrentThreadIsOwner() const { |
| 90 #if defined(WEBRTC_WIN) | 90 #if defined(WEBRTC_WIN) |
| 91 return crit_.OwningThread == reinterpret_cast<HANDLE>(GetCurrentThreadId()); | 91 // OwningThread has type HANDLE but actually contains the Thread ID: |
| 92 // http://stackoverflow.com/questions/12675301/why-is-the-owningthread-member-
of-critical-section-of-type-handle-when-it-is-de |
| 93 // Converting through size_t avoids the VS 2015 warning C4312: conversion from |
| 94 // 'type1' to 'type2' of greater size |
| 95 return crit_.OwningThread == |
| 96 reinterpret_cast<HANDLE>(static_cast<size_t>(GetCurrentThreadId())); |
| 92 #else | 97 #else |
| 93 #if CS_DEBUG_CHECKS | 98 #if CS_DEBUG_CHECKS |
| 94 return pthread_equal(thread_, pthread_self()); | 99 return pthread_equal(thread_, pthread_self()); |
| 95 #else | 100 #else |
| 96 return true; | 101 return true; |
| 97 #endif // CS_DEBUG_CHECKS | 102 #endif // CS_DEBUG_CHECKS |
| 98 #endif | 103 #endif |
| 99 } | 104 } |
| 100 | 105 |
| 101 bool CriticalSection::IsLocked() const { | 106 bool CriticalSection::IsLocked() const { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 GlobalLockScope::GlobalLockScope(GlobalLockPod* lock) | 160 GlobalLockScope::GlobalLockScope(GlobalLockPod* lock) |
| 156 : lock_(lock) { | 161 : lock_(lock) { |
| 157 lock_->Lock(); | 162 lock_->Lock(); |
| 158 } | 163 } |
| 159 | 164 |
| 160 GlobalLockScope::~GlobalLockScope() { | 165 GlobalLockScope::~GlobalLockScope() { |
| 161 lock_->Unlock(); | 166 lock_->Unlock(); |
| 162 } | 167 } |
| 163 | 168 |
| 164 } // namespace rtc | 169 } // namespace rtc |
| OLD | NEW |