| // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "base/synchronization/lock_impl.h" |
| #include "base/logging.h" |
| // In debug, setup attributes for lock error checking. |
| int rv = pthread_mutexattr_init(&mta); |
| rv = pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_ERRORCHECK); |
| rv = pthread_mutex_init(&os_lock_, &mta); |
| rv = pthread_mutexattr_destroy(&mta); |
| // In release, go with the default lock attributes. |
| pthread_mutex_init(&os_lock_, NULL); |
| int rv = pthread_mutex_destroy(&os_lock_); |
| int rv = pthread_mutex_trylock(&os_lock_); |
| DCHECK(rv == 0 || rv == EBUSY); |
| int rv = pthread_mutex_lock(&os_lock_); |
| void LockImpl::Unlock() { |
| int rv = pthread_mutex_unlock(&os_lock_); |