================ @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_TARGET_TARGETAPILOCK_H +#define LLDB_TARGET_TARGETAPILOCK_H + +#include "lldb/lldb-forward.h" +#include <mutex> + +namespace lldb_private { + +/// A Lockable handle over a Target's API mutex, returned by +/// Target::GetAPIMutex() and backing the public lldb::SBMutex. +/// +/// 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. Move-only; the +/// destructor releases the lock if one is currently held. +class TargetAPILock { ---------------- JDevlieghere wrote:
Is this class meant to be a lock or a mutex? This class currently seems like an amalgamation of the two. It conforms to the lockable interface (like SBMutex) and backs it, but it's called lock and behaves half like an RAII object that unlocks on destruction but doesn't lock on construction. https://github.com/llvm/llvm-project/pull/212872 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
