[clang] [llvm] [Support] Introduce new `AdvisoryLock` interface (PR #130989)
Michael Spencer via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 12 13:13:33 PDT 2025
================
@@ -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.
----------------
Bigcheese wrote:
```suggestion
/// the lock to be unlocked will validate that the computation produced a valid result.
```
https://github.com/llvm/llvm-project/pull/130989
More information about the cfe-commits
mailing list