summaryrefslogtreecommitdiff
path: root/Kernel/Locking
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-21 23:27:23 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-22 03:34:09 +0200
commit81d990b551b79af027b44463b1e7da35ec62c1b4 (patch)
tree79942885a751fb768a65dd51bdc739e73beb1c8c /Kernel/Locking
parent60a4da8e204223d09c55cee0d4e9a586ecd95982 (diff)
downloadserenity-81d990b551b79af027b44463b1e7da35ec62c1b4.zip
Kernel: Remove some unused classes from Kernel/Locking/
Diffstat (limited to 'Kernel/Locking')
-rw-r--r--Kernel/Locking/NonnullRefContendedPtr.h17
-rw-r--r--Kernel/Locking/NonnullRefContendedPtrVector.h17
-rw-r--r--Kernel/Locking/RefContendedPtr.h17
-rw-r--r--Kernel/Locking/RefCountedContended.h80
4 files changed, 0 insertions, 131 deletions
diff --git a/Kernel/Locking/NonnullRefContendedPtr.h b/Kernel/Locking/NonnullRefContendedPtr.h
deleted file mode 100644
index 47ee850805..0000000000
--- a/Kernel/Locking/NonnullRefContendedPtr.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2021, the SerenityOS developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/NonnullRefPtr.h>
-#include <Kernel/Locking/RefCountedContended.h>
-
-namespace Kernel {
-
-template<typename T>
-using NonnullRefContendedPtr = NonnullRefPtr<RefCountedContended<T>>;
-
-}
diff --git a/Kernel/Locking/NonnullRefContendedPtrVector.h b/Kernel/Locking/NonnullRefContendedPtrVector.h
deleted file mode 100644
index bb7f2cbf2c..0000000000
--- a/Kernel/Locking/NonnullRefContendedPtrVector.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2021, the SerenityOS developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/NonnullPtrVector.h>
-#include <Kernel/Locking/NonnullRefContendedPtr.h>
-
-namespace Kernel {
-
-template<typename T, size_t inline_capacity = 0>
-using NonnullRefContendedPtrVector = AK::NonnullPtrVector<NonnullRefContendedPtr<T>, inline_capacity>;
-
-}
diff --git a/Kernel/Locking/RefContendedPtr.h b/Kernel/Locking/RefContendedPtr.h
deleted file mode 100644
index 314406eca9..0000000000
--- a/Kernel/Locking/RefContendedPtr.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2021, the SerenityOS developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/RefPtr.h>
-#include <Kernel/Locking/RefCountedContended.h>
-
-namespace Kernel {
-
-template<typename T>
-using RefContendedPtr = RefPtr<RefCountedContended<T>>;
-
-}
diff --git a/Kernel/Locking/RefCountedContended.h b/Kernel/Locking/RefCountedContended.h
deleted file mode 100644
index ed8424a79d..0000000000
--- a/Kernel/Locking/RefCountedContended.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2021, the SerenityOS developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/RefCounted.h>
-#include <Kernel/Locking/ContendedResource.h>
-#include <Kernel/Locking/LockLocation.h>
-#include <Kernel/Locking/Mutex.h>
-
-namespace Kernel {
-
-template<typename T>
-class RefCountedContended : public ContendedResource
- , public AK::RefCountedBase {
- AK_MAKE_NONCOPYABLE(RefCountedContended);
- AK_MAKE_NONMOVABLE(RefCountedContended);
-
-protected:
- using LockedShared = LockedResource<T const, LockMode::Shared>;
- using LockedExclusive = LockedResource<T, LockMode::Exclusive>;
-
- LockedShared lock_shared(LockLocation const& location) const { return LockedShared(static_cast<T const*>(this), this->ContendedResource::m_mutex, location); }
- LockedExclusive lock_exclusive(LockLocation const& location) { return LockedExclusive(static_cast<T*>(this), this->ContendedResource::m_mutex, location); }
-
-public:
- RefCountedContended() = default;
-
- bool unref() const
- {
- auto new_ref_count = deref_base();
- if (new_ref_count == 0) {
- AK::call_will_be_destroyed_if_present(static_cast<T*>(const_cast<RefCountedContended*>(this)->lock_exclusive().get()));
- delete static_cast<const T*>(this);
- return true;
- } else if (new_ref_count == 1) {
- AK::call_one_ref_left_if_present(static_cast<T*>(const_cast<RefCountedContended*>(this)->lock_exclusive().get()));
- }
- return false;
- }
-
- template<typename Callback>
- decltype(auto) with_shared(Callback callback, LockLocation const& location = LockLocation::current()) const
- {
- auto lock = lock_shared(location);
- return callback(*lock);
- }
-
- template<typename Callback>
- decltype(auto) with_exclusive(Callback callback, LockLocation const& location = LockLocation::current())
- {
- auto lock = lock_exclusive(location);
- return callback(*lock);
- }
-
- template<typename Callback>
- void for_each_shared(Callback callback, LockLocation const& location = LockLocation::current()) const
- {
- with_shared([&](const auto& value) {
- for (auto& item : value)
- callback(item);
- },
- location);
- }
-
- template<typename Callback>
- void for_each_exclusive(Callback callback, LockLocation const& location = LockLocation::current())
- {
- with_exclusive([&](auto& value) {
- for (auto& item : value)
- callback(item);
- },
- location);
- }
-};
-
-}