curl-cpp
static c++17 wrapper for curl with -fno-exceptions support
Main Page
Classes
Files
Examples
File List
utils
shared_mutex.hpp
1
#
ifndef
__curl_cpp_utils_shared_mutex_HPP__
2
#
define
__curl_cpp_utils_shared_mutex_HPP__
3
4
#
include
<
pthread
.
h
>
5
6
namespace
curl::utils {
7
/**
8
* C++ RAII wrapper for pthread_rwlock_t.
9
*
10
* To use this interface, you'd have to add
11
* -lpthread to LDFLAGS of your project.
12
*
13
* This class is designed specifically for
14
* curl::Share, which requires a std::shared_mutex
15
* like interface, but have to be able to unlock
16
* shared lock/normal lock with a single function.
17
*/
18
class
shared_mutex
{
19
pthread_rwlock_t rwlock;
20
21
public
:
22
/**
23
* On failure, call err to terminate the program.
24
*/
25
shared_mutex
()
noexcept
;
26
27
shared_mutex(
const
shared_mutex
&) =
delete
;
28
shared_mutex(
shared_mutex
&&) =
delete
;
29
30
shared_mutex
& operator = (
const
shared_mutex
&) =
delete
;
31
shared_mutex
& operator = (
shared_mutex
&&) =
delete
;
32
33
~shared_mutex();
34
35
/**
36
* Undefined behavior if deadlocks.
37
*/
38
void
lock
()
noexcept
;
39
/**
40
* Undefined behavior if deadlocks.
41
*/
42
void
lock_shared
()
noexcept
;
43
44
/**
45
* One unlock function for lock()/lock_shared().
46
*/
47
void
unlock
()
noexcept
;
48
};
49
}
/* namespace curl::utils */
50
51
#
endif
curl::utils::shared_mutex::lock_shared
void lock_shared() noexcept
Definition:
shared_mutex.cc:34
curl::utils::shared_mutex::lock
void lock() noexcept
Definition:
shared_mutex.cc:30
curl::utils::shared_mutex
Definition:
shared_mutex.hpp:18
curl::utils::shared_mutex::unlock
void unlock() noexcept
Definition:
shared_mutex.cc:42
curl::utils::shared_mutex::shared_mutex
shared_mutex() noexcept
Definition:
shared_mutex.cc:14
Generated on Sat Aug 1 2020 00:13:48 for curl-cpp by
1.8.17