security/sandbox/chromium/base/synchronization/lock.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/chromium/base/synchronization/lock.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +// This file is used for debugging assertion support.  The Lock class
     1.9 +// is functionally a wrapper around the LockImpl class, so the only
    1.10 +// real intelligence in the class is in the debugging logic.
    1.11 +
    1.12 +#if !defined(NDEBUG)
    1.13 +
    1.14 +#include "base/synchronization/lock.h"
    1.15 +#include "base/logging.h"
    1.16 +
    1.17 +namespace base {
    1.18 +
    1.19 +const PlatformThreadId kNoThreadId = static_cast<PlatformThreadId>(0);
    1.20 +
    1.21 +Lock::Lock() : lock_() {
    1.22 +  owned_by_thread_ = false;
    1.23 +  owning_thread_id_ = kNoThreadId;
    1.24 +}
    1.25 +
    1.26 +Lock::~Lock() {
    1.27 +  DCHECK(!owned_by_thread_);
    1.28 +  DCHECK_EQ(kNoThreadId, owning_thread_id_);
    1.29 +}
    1.30 +
    1.31 +void Lock::AssertAcquired() const {
    1.32 +  DCHECK(owned_by_thread_);
    1.33 +  DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
    1.34 +}
    1.35 +
    1.36 +void Lock::CheckHeldAndUnmark() {
    1.37 +  DCHECK(owned_by_thread_);
    1.38 +  DCHECK_EQ(owning_thread_id_, PlatformThread::CurrentId());
    1.39 +  owned_by_thread_ = false;
    1.40 +  owning_thread_id_ = kNoThreadId;
    1.41 +}
    1.42 +
    1.43 +void Lock::CheckUnheldAndMark() {
    1.44 +  DCHECK(!owned_by_thread_);
    1.45 +  owned_by_thread_ = true;
    1.46 +  owning_thread_id_ = PlatformThread::CurrentId();
    1.47 +}
    1.48 +
    1.49 +}  // namespace base
    1.50 +
    1.51 +#endif  // NDEBUG

mercurial