================ @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// 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 LLVM_SUPPORT_ADVISORYLOCK_H +#define LLVM_SUPPORT_ADVISORYLOCK_H + +#include "llvm/Support/Error.h" + +namespace llvm { +/// Describes the result of waiting for the owner to release the lock. +enum class WaitForUnlockResult { + /// The lock was released successfully. + Success, + /// Owner died while holding the lock. + OwnerDied, + /// Reached timeout while waiting for the owner to release the lock. + Timeout, +}; + +/// A synchronization primitive with weak mutual exclusion guarantees. +/// Implementations of this interface may allow multiple threads/processes to +/// acquire the lock simultaneously. Typically, threads/processes waiting for +/// the lock to be unlocked will validate the computation produced valid result. +class AdvisoryLock { +public: + /// Tries to acquire the lock without blocking. + /// + /// \returns true if the lock was successfully acquired (owned lock), false if + /// the lock is already held by someone else (shared lock), or \c Error in ---------------- Bigcheese wrote:
I think the term "shared lock" is misleading. Generally that means that you have a read lock, but here it just means you don't own the lock. https://github.com/llvm/llvm-project/pull/130989 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits