-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmutex_lock.h
More file actions
45 lines (36 loc) · 777 Bytes
/
mutex_lock.h
File metadata and controls
45 lines (36 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2014 The Trident Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
//
#ifndef _TRIDENT_MUTEX_LOCK_H_
#define _TRIDENT_MUTEX_LOCK_H_
#include <pthread.h>
namespace trident {
class ConditionVariable;
class MutexLock
{
public:
MutexLock()
{
pthread_mutex_init(&_lock, NULL);
}
~MutexLock()
{
pthread_mutex_destroy(&_lock);
}
void lock()
{
pthread_mutex_lock(&_lock);
}
void unlock()
{
pthread_mutex_unlock(&_lock);
}
private:
friend class ConditionVariable;
pthread_mutex_t _lock;
};
} // namespace trident
#endif // _TRIDENT_MUTEX_LOCK_H_
/* vim: set ts=4 sw=4 sts=4 tw=100 */