mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
Add new shared pointer and make use of it
This commit is contained in:
31
arm9/source/core/SharedPtr.cpp
Normal file
31
arm9/source/core/SharedPtr.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "common.h"
|
||||
#include <libtwl/rtos/rtosIrq.h>
|
||||
#include "SharedPtr.h"
|
||||
|
||||
void SharedPtrBase::ResetIntern()
|
||||
{
|
||||
auto refCount = _refCount;
|
||||
_object = nullptr;
|
||||
_refCount = nullptr;
|
||||
u32 irq = rtos_disableIrqs(); // 1
|
||||
if (--refCount->refCount == 0) [[gnu::unlikely]]
|
||||
{
|
||||
refCount->weakRefCount++; // ensure the ref count is not destructed elsewhere
|
||||
rtos_restoreIrqs(irq); // 1
|
||||
refCount->DestructObject();
|
||||
irq = rtos_disableIrqs(); // 2
|
||||
if (--refCount->weakRefCount == 0) [[gnu::unlikely]]
|
||||
{
|
||||
rtos_restoreIrqs(irq); // 2
|
||||
delete refCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
rtos_restoreIrqs(irq); // 2
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rtos_restoreIrqs(irq); // 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user