diff --git a/headers/private/shared/PthreadMutexLocker.h b/headers/private/shared/PthreadMutexLocker.h new file mode 100644 index 0000000000..db0e69516f --- /dev/null +++ b/headers/private/shared/PthreadMutexLocker.h @@ -0,0 +1,42 @@ +/* + * Copyright 2013, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + */ +#ifndef _PTHREAD_MUTEX_LOCKER_H +#define _PTHREAD_MUTEX_LOCKER_H + + +#include + +#include + + +namespace BPrivate { + + +class AutoLockerMutexLocking { +public: + inline bool Lock(pthread_mutex_t* lockable) + { + return pthread_mutex_lock(lockable) == 0; + } + + inline void Unlock(pthread_mutex_t* lockable) + { + pthread_mutex_unlock(lockable); + } +}; + + +typedef AutoLocker PthreadMutexLocker; + + +} // namespace BPrivate + +using BPrivate::PthreadMutexLocker; + + +#endif // _PTHREAD_MUTEX_LOCKER_H