|
LLDB mainline
|
A Lockable handle over a Target's API mutex, returned by Target::GetAPIMutex() and backing the public lldb::SBMutex. More...
#include <TargetAPIMutex.h>
Public Member Functions | |
| TargetAPIMutex ()=default | |
| TargetAPIMutex (lldb::TargetSP target_sp) | |
| TargetAPIMutex (TargetAPIMutex &&other) noexcept=default | |
| TargetAPIMutex & | operator= (TargetAPIMutex &&other) noexcept=default |
| TargetAPIMutex (const TargetAPIMutex &)=delete | |
| TargetAPIMutex & | operator= (const TargetAPIMutex &)=delete |
| void | lock () |
| bool | try_lock () |
| void | unlock () |
Private Attributes | |
| std::shared_ptr< std::recursive_mutex > | m_mutex |
| An aliasing shared_ptr into m_target_sp's own mutex, resolved fresh on every lock()/try_lock() call. | |
| lldb::TargetSP | m_target_sp |
A Lockable handle over a Target's API mutex, returned by Target::GetAPIMutex() and backing the public lldb::SBMutex.
Behaves like std::recursive_mutex: lock()/try_lock()/unlock() drive the actual synchronization, with the same contract (unlock() without a matching successful lock()/try_lock() is caller error). It carries no RAII of its own; wrap it in std::lock_guard<TargetAPIMutex> or std::unique_lock<TargetAPIMutex> for scope-based locking, exactly as with any other Lockable.
A handle may be constructed on one thread and then locked/unlocked on a different one, so lock()/try_lock() (re-)resolve which real mutex to use fresh on every call, rather than caching a single resolution for the handle's lifetime. The matching unlock() replays the exact resolution that call produced, rather than re-resolving, so the calling thread's policy at unlock() time can't cause it to release the wrong mutex (or fail to release the one it actually holds).
Default-constructed (or moved-from) handles are a genuine no-op: no synchronization primitive is touched at all.
Definition at line 39 of file TargetAPIMutex.h.
|
default |
Referenced by operator=(), operator=(), TargetAPIMutex(), and TargetAPIMutex().
|
inlineexplicit |
Definition at line 42 of file TargetAPIMutex.h.
References m_target_sp.
|
defaultnoexcept |
References TargetAPIMutex().
|
delete |
References TargetAPIMutex().
| void TargetAPIMutex::lock | ( | ) |
Definition at line 15 of file TargetAPIMutex.cpp.
References lldb_private::PolicyStack::Current(), lldb_private::PolicyStack::Get(), m_mutex, m_target_sp, lldb_private::Policy::Private, and lldb_private::Policy::view.
|
delete |
References TargetAPIMutex().
|
defaultnoexcept |
References TargetAPIMutex().
| bool TargetAPIMutex::try_lock | ( | ) |
Definition at line 27 of file TargetAPIMutex.cpp.
References lldb_private::PolicyStack::Current(), lldb_private::PolicyStack::Get(), m_mutex, m_target_sp, lldb_private::Policy::Private, and lldb_private::Policy::view.
|
inline |
Definition at line 53 of file TargetAPIMutex.h.
References m_mutex.
|
private |
An aliasing shared_ptr into m_target_sp's own mutex, resolved fresh on every lock()/try_lock() call.
Shares m_target_sp's control block (keeping the Target alive) while pointing at the mutex living inside it. Null when this handle is a genuine no-op.
Definition at line 63 of file TargetAPIMutex.h.
Referenced by lock(), try_lock(), and unlock().
|
private |
Definition at line 64 of file TargetAPIMutex.h.
Referenced by lock(), TargetAPIMutex(), and try_lock().