2#include <ossia/detail/config.hpp>
5#if defined(OSSIA_SHARED_MUTEX_AVAILABLE)
11#if defined(OSSIA_SHARED_MUTEX_AVAILABLE)
14using mutex_t = std::mutex;
15using lock_t = std::lock_guard<mutex_t>;
17using mutex_t = std::shared_mutex;
18using lock_t = std::lock_guard<mutex_t>;
21using shared_mutex_t = std::shared_timed_mutex;
22using write_lock_t = std::lock_guard<shared_mutex_t>;
23using read_lock_t = std::shared_lock<shared_mutex_t>;
25using mutex_t = std::mutex;
26using shared_mutex_t = std::mutex;
27using lock_t = std::lock_guard<mutex_t>;
28using write_lock_t = std::lock_guard<mutex_t>;
29using read_lock_t = std::lock_guard<mutex_t>;
35#if defined(__clang__) && (!defined(SWIG))
36#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
38#define THREAD_ANNOTATION_ATTRIBUTE__(x)
41#define TS_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
43#define TS_SCOPED_CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
45#define TS_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
47#define TS_PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
49#define TS_ACQUIRED_BEFORE(...) \
50 THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
52#define TS_ACQUIRED_AFTER(...) THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
54#define TS_REQUIRES(...) THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
56#define TS_REQUIRES_SHARED(...) \
57 THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
59#define TS_ACQUIRE(...) THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
61#define TS_ACQUIRE_SHARED(...) \
62 THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
64#define TS_RELEASE(...) THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
66#define TS_RELEASE_SHARED(...) \
67 THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
69#define TS_RELEASE_GENERIC(...) \
70 THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__))
72#define TS_TRY_ACQUIRE(...) \
73 THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
75#define TS_TRY_ACQUIRE_SHARED(...) \
76 THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
78#define TS_EXCLUDES(...) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
80#define TS_ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
82#define TS_ASSERT_SHARED_CAPABILITY(x) \
83 THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
85#define TS_RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
87#define TS_NO_THREAD_SAFETY_ANALYSIS \
88 THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)