aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-09-29 10:42:57 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-09-29 10:42:57 +0200
commit2750018596e2379a868d526262ce567a7042154d (patch)
tree4d49fb946babf0374794312ac2209c2e0f1cdfe3 /libs/kstd
parentee7ad8a8996cd48eb3bb4604732096572d006712 (diff)
downloadkernel-2750018596e2379a868d526262ce567a7042154d.tar.xz
kernel-2750018596e2379a868d526262ce567a7042154d.zip
kstd/concepts: add lockable concept
Diffstat (limited to 'libs/kstd')
-rw-r--r--libs/kstd/kstd/bits/concepts.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/libs/kstd/kstd/bits/concepts.hpp b/libs/kstd/kstd/bits/concepts.hpp
index af9f6d2c..d40b8de2 100644
--- a/libs/kstd/kstd/bits/concepts.hpp
+++ b/libs/kstd/kstd/bits/concepts.hpp
@@ -29,6 +29,21 @@ namespace kstd::bits
lockable.unlock();
};
+ //! Requirements on a basic lockable object.
+ //!
+ //! Given:
+ //! - @p L, a class type
+ //! - @p l, an instance of @p L
+ //!
+ //! @p L is said to be **lockable**, iff. it is a basic_lockable and the following expression is valid:
+ //! - @p l.try_lock();
+ template<typename LockableType>
+ concept lockable = basic_lockable<LockableType> && requires(LockableType & lockable) {
+ //! Try to lock the lockable object, returning @p true iff. the locking was successful, @p false
+ //! otherwise.
+ { lockable.try_lock() } -> std::same_as<bool>;
+ };
+
template<typename SuspectType>
concept allocator_like = requires(SuspectType & suspect) {
typename SuspectType::value_type;