mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-17 07:47:33 +01:00
hle: kernel: KAutoObjectWithListContainer: Use boost::instrusive::rbtree.
- Fixes some crashes introduced by our common intrusive red/black tree impl.
This commit is contained in:
parent
27ce97fd42
commit
6119836795
@ -7,10 +7,11 @@
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
|
||||
#include <boost/intrusive/rbtree.hpp>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/intrusive_red_black_tree.h"
|
||||
#include "core/hle/kernel/k_class_token.h"
|
||||
|
||||
namespace Kernel {
|
||||
@ -175,7 +176,7 @@ private:
|
||||
|
||||
class KAutoObjectWithListContainer;
|
||||
|
||||
class KAutoObjectWithList : public KAutoObject {
|
||||
class KAutoObjectWithList : public KAutoObject, public boost::intrusive::set_base_hook<> {
|
||||
public:
|
||||
explicit KAutoObjectWithList(KernelCore& kernel_) : KAutoObject(kernel_) {}
|
||||
|
||||
@ -192,6 +193,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
friend bool operator<(const KAutoObjectWithList& left, const KAutoObjectWithList& right) {
|
||||
return &left < &right;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual u64 GetId() const {
|
||||
return reinterpret_cast<u64>(this);
|
||||
@ -203,8 +208,6 @@ public:
|
||||
|
||||
private:
|
||||
friend class KAutoObjectWithListContainer;
|
||||
|
||||
Common::IntrusiveRedBlackTreeNode list_node;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -9,13 +9,13 @@ namespace Kernel {
|
||||
void KAutoObjectWithListContainer::Register(KAutoObjectWithList* obj) {
|
||||
KScopedLightLock lk(m_lock);
|
||||
|
||||
m_object_list.insert(*obj);
|
||||
m_object_list.insert_unique(*obj);
|
||||
}
|
||||
|
||||
void KAutoObjectWithListContainer::Unregister(KAutoObjectWithList* obj) {
|
||||
KScopedLightLock lk(m_lock);
|
||||
|
||||
m_object_list.erase(m_object_list.iterator_to(*obj));
|
||||
m_object_list.erase(*obj);
|
||||
}
|
||||
|
||||
size_t KAutoObjectWithListContainer::GetOwnedCount(KProcess* owner) {
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <boost/intrusive/rbtree.hpp>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
@ -23,8 +25,7 @@ class KAutoObjectWithListContainer {
|
||||
YUZU_NON_MOVEABLE(KAutoObjectWithListContainer);
|
||||
|
||||
public:
|
||||
using ListType = Common::IntrusiveRedBlackTreeMemberTraits<
|
||||
&KAutoObjectWithList::list_node>::TreeType<KAutoObjectWithList>;
|
||||
using ListType = boost::intrusive::rbtree<KAutoObjectWithList>;
|
||||
|
||||
public:
|
||||
class ListAccessor : public KScopedLightLock {
|
||||
|
@ -16,11 +16,11 @@ namespace Kernel {
|
||||
KClientPort::KClientPort(KernelCore& kernel_) : KSynchronizationObject{kernel_} {}
|
||||
KClientPort::~KClientPort() = default;
|
||||
|
||||
void KClientPort::Initialize(KPort* parent_, s32 max_sessions_, std::string&& name_) {
|
||||
void KClientPort::Initialize(KPort* parent_port_, s32 max_sessions_, std::string&& name_) {
|
||||
// Set member variables.
|
||||
num_sessions = 0;
|
||||
peak_sessions = 0;
|
||||
parent = parent_;
|
||||
parent = parent_port_;
|
||||
max_sessions = max_sessions_;
|
||||
name = std::move(name_);
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ public:
|
||||
explicit KClientSession(KernelCore& kernel_);
|
||||
~KClientSession() override;
|
||||
|
||||
void Initialize(KSession* parent_, std::string&& name_) {
|
||||
void Initialize(KSession* parent_session_, std::string&& name_) {
|
||||
// Set member variables.
|
||||
parent = parent_;
|
||||
parent = parent_session_;
|
||||
name = std::move(name_);
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,9 @@ public:
|
||||
explicit KReadableEvent(KernelCore& kernel_);
|
||||
~KReadableEvent() override;
|
||||
|
||||
void Initialize(KEvent* parent_, std::string&& name_) {
|
||||
void Initialize(KEvent* parent_event_, std::string&& name_) {
|
||||
is_signaled = false;
|
||||
parent = parent_;
|
||||
parent = parent_event_;
|
||||
name = std::move(name_);
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,9 @@ namespace Kernel {
|
||||
KServerPort::KServerPort(KernelCore& kernel_) : KSynchronizationObject{kernel_} {}
|
||||
KServerPort::~KServerPort() = default;
|
||||
|
||||
void KServerPort::Initialize(KPort* parent_, std::string&& name_) {
|
||||
void KServerPort::Initialize(KPort* parent_port_, std::string&& name_) {
|
||||
// Set member variables.
|
||||
parent = parent_;
|
||||
parent = parent_port_;
|
||||
name = std::move(name_);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
explicit KServerPort(KernelCore& kernel_);
|
||||
~KServerPort() override;
|
||||
|
||||
void Initialize(KPort* parent_, std::string&& name_);
|
||||
void Initialize(KPort* parent_port_, std::string&& name_);
|
||||
|
||||
/// Whether or not this server port has an HLE handler available.
|
||||
bool HasSessionRequestHandler() const {
|
||||
|
@ -29,10 +29,10 @@ KServerSession::KServerSession(KernelCore& kernel_) : KSynchronizationObject{ker
|
||||
|
||||
KServerSession::~KServerSession() {}
|
||||
|
||||
void KServerSession::Initialize(KSession* parent_, std::string&& name_,
|
||||
void KServerSession::Initialize(KSession* parent_session_, std::string&& name_,
|
||||
std::shared_ptr<SessionRequestManager> manager_) {
|
||||
// Set member variables.
|
||||
parent = parent_;
|
||||
parent = parent_session_;
|
||||
name = std::move(name_);
|
||||
|
||||
if (manager_) {
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
|
||||
void Destroy() override;
|
||||
|
||||
void Initialize(KSession* parent_, std::string&& name_,
|
||||
void Initialize(KSession* parent_session_, std::string&& name_,
|
||||
std::shared_ptr<SessionRequestManager> manager_);
|
||||
|
||||
KSession* GetParent() {
|
||||
|
@ -13,8 +13,8 @@ KWritableEvent::KWritableEvent(KernelCore& kernel_)
|
||||
|
||||
KWritableEvent::~KWritableEvent() = default;
|
||||
|
||||
void KWritableEvent::Initialize(KEvent* parent_, std::string&& name_) {
|
||||
parent = parent_;
|
||||
void KWritableEvent::Initialize(KEvent* parent_event_, std::string&& name_) {
|
||||
parent = parent_event_;
|
||||
name = std::move(name_);
|
||||
parent->GetReadableEvent().Open();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user