no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / memory / build / Mutex.cpp
blob14502102935254670c0966a32e2bfbda8e54bfba
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "Mutex.h"
7 #include <errno.h>
9 #include "mozilla/Assertions.h"
11 bool Mutex::TryLock() {
12 #if defined(XP_WIN)
13 return !!TryEnterCriticalSection(&mMutex);
14 #elif defined(XP_DARWIN)
15 return os_unfair_lock_trylock(&mMutex);
16 #else
17 switch (pthread_mutex_trylock(&mMutex)) {
18 case 0:
19 return true;
20 case EBUSY:
21 return false;
22 default:
23 MOZ_CRASH("pthread_mutex_trylock error.");
25 #endif