forked from sony/nmos-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared_mutex.h
More file actions
40 lines (31 loc) · 1.2 KB
/
shared_mutex.h
File metadata and controls
40 lines (31 loc) · 1.2 KB
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
#ifndef BST_SHARED_MUTEX_H
#define BST_SHARED_MUTEX_H
// Provide bst::shared_mutex, bst::shared_lock etc. using either std:: or boost:: symbols
#ifndef BST_THREAD_BOOST
#include <condition_variable>
#include <shared_mutex>
namespace bst_shared_mutex = std;
namespace bst_shared_mutex_condition_variable_any = std;
#else
#include <boost/thread/lock_types.hpp>
#include <boost/thread/shared_mutex.hpp>
namespace bst_shared_mutex = boost;
#ifdef _WIN32
// Note:: Windows boost::condition_variable_any::wait throws nested lock exceptions when boost::shared_mutex has reached the
// maximum number of exclusive_waiting locks. A modified version of the boost::condition_variable_any was created to address this issue.
#include "boost/thread/win32_condition_variable.hpp"
namespace bst_shared_mutex_condition_variable_any = boost::experimental;
#else
#include <boost/thread/condition_variable.hpp>
namespace bst_shared_mutex_condition_variable_any = boost;
#endif
#endif
namespace bst
{
using bst_shared_mutex::shared_mutex;
using bst_shared_mutex::shared_lock;
using bst_shared_mutex_condition_variable_any::condition_variable_any;
using bst_shared_mutex::nano;
using bst_shared_mutex::cv_status;
}
#endif