summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_auto_object.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-04 04:11:46 +0200
committerbunnei <bunneidev@gmail.com>2021-05-06 01:40:50 +0200
commitda7e9553dea4b1eaefb71aca8642ccce7c7f50fb (patch)
tree3da10a60005ddcc4237900eb5e7473fe7b006152 /src/core/hle/kernel/k_auto_object.h
parenthle: kernel: svc: Migrate GetThreadPriority, StartThread, and ExitThread. (diff)
downloadyuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar
yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.gz
yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.bz2
yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.lz
yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.xz
yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.zst
yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.zip
Diffstat (limited to 'src/core/hle/kernel/k_auto_object.h')
-rw-r--r--src/core/hle/kernel/k_auto_object.h28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/core/hle/kernel/k_auto_object.h b/src/core/hle/kernel/k_auto_object.h
index 567dad204..64c012d44 100644
--- a/src/core/hle/kernel/k_auto_object.h
+++ b/src/core/hle/kernel/k_auto_object.h
@@ -11,9 +11,11 @@
#include "common/common_types.h"
#include "common/intrusive_red_black_tree.h"
#include "core/hle/kernel/k_class_token.h"
+#include "core/hle/kernel/object.h"
namespace Kernel {
+class KernelCore;
class Process;
#define KERNEL_AUTOOBJECT_TRAITS(CLASS, BASE_CLASS) \
@@ -46,7 +48,7 @@ public:
\
private:
-class KAutoObject {
+class KAutoObject : public Object {
protected:
class TypeObj {
private:
@@ -84,11 +86,14 @@ private:
private:
std::atomic<u32> m_ref_count;
+protected:
+ KernelCore& kernel;
+
public:
static KAutoObject* Create(KAutoObject* ptr);
public:
- constexpr explicit KAutoObject() : m_ref_count(0) {}
+ explicit KAutoObject(KernelCore& kernel_) : Object{kernel_}, m_ref_count(0), kernel(kernel_) {}
virtual ~KAutoObject() {}
// Destroy is responsible for destroying the auto object's resources when ref_count hits zero.
@@ -97,9 +102,7 @@ public:
}
// Finalize is responsible for cleaning up resource, but does not destroy the object.
- virtual void Finalize() {
- UNIMPLEMENTED();
- }
+ virtual void Finalize() {}
virtual Process* GetOwner() const {
return nullptr;
@@ -179,7 +182,12 @@ private:
private:
Common::IntrusiveRedBlackTreeNode list_node;
+protected:
+ KernelCore& kernel;
+
public:
+ explicit KAutoObjectWithList(KernelCore& kernel_) : KAutoObject(kernel_), kernel(kernel_) {}
+
static int Compare(const KAutoObjectWithList& lhs, const KAutoObjectWithList& rhs) {
const u64 lid = lhs.GetId();
const u64 rid = rhs.GetId();
@@ -208,7 +216,7 @@ private:
friend class KScopedAutoObject;
private:
- T* m_obj;
+ T* m_obj{};
private:
constexpr void Swap(KScopedAutoObject& rhs) {
@@ -216,8 +224,8 @@ private:
}
public:
- constexpr KScopedAutoObject() : m_obj(nullptr) { // ...
- }
+ constexpr KScopedAutoObject() = default;
+
constexpr KScopedAutoObject(T* o) : m_obj(o) {
if (m_obj != nullptr) {
m_obj->Open();
@@ -273,6 +281,10 @@ public:
return m_obj;
}
+ constexpr T* GetPointerUnsafe() const {
+ return m_obj;
+ }
+
constexpr T* ReleasePointerUnsafe() {
T* ret = m_obj;
m_obj = nullptr;