blob: 4a1d466e405845fefd8272ad5b377a8e693cd672 (
plain) (
blame)
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
******************************************************************************
* @author Oivind H. Danielsen
* @date Creation date: 2000-02-02
* @file
* Class definition and implementation for FastOS_UNIX_Mutex
*****************************************************************************/
#pragma once
#include <vespa/fastos/mutex.h>
class FastOS_UNIX_Mutex : public FastOS_MutexInterface
{
private:
FastOS_UNIX_Mutex(const FastOS_UNIX_Mutex &other);
FastOS_UNIX_Mutex & operator = (const FastOS_UNIX_Mutex &other);
protected:
pthread_mutex_t _mutex;
public:
FastOS_UNIX_Mutex();
~FastOS_UNIX_Mutex();
bool TryLock () override {
return pthread_mutex_trylock(&_mutex) == 0;
}
void Lock() override {
pthread_mutex_lock(&_mutex);
}
void Unlock() override {
pthread_mutex_unlock(&_mutex);
}
};
|