|
@@ -1,6 +1,5 @@ |
|
|
#pragma once |
|
|
#pragma once |
|
|
#include <common.hpp> |
|
|
#include <common.hpp> |
|
|
#include <atomic> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace rack { |
|
|
namespace rack { |
|
@@ -8,7 +7,7 @@ namespace rack { |
|
|
|
|
|
|
|
|
struct WeakHandle { |
|
|
struct WeakHandle { |
|
|
void* ptr; |
|
|
void* ptr; |
|
|
std::atomic<size_t> count{0}; |
|
|
|
|
|
|
|
|
size_t count = 0; |
|
|
WeakHandle(void* ptr) : ptr(ptr) {} |
|
|
WeakHandle(void* ptr) : ptr(ptr) {} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@@ -89,10 +88,13 @@ struct WeakPtr { |
|
|
return nullptr; |
|
|
return nullptr; |
|
|
return reinterpret_cast<T*>(weakHandle->ptr); |
|
|
return reinterpret_cast<T*>(weakHandle->ptr); |
|
|
} |
|
|
} |
|
|
|
|
|
T* operator->() const { |
|
|
|
|
|
return get(); |
|
|
|
|
|
} |
|
|
T& operator*() const { |
|
|
T& operator*() const { |
|
|
return *get(); |
|
|
return *get(); |
|
|
} |
|
|
} |
|
|
T* operator->() const { |
|
|
|
|
|
|
|
|
operator T*() const { |
|
|
return get(); |
|
|
return get(); |
|
|
} |
|
|
} |
|
|
explicit operator bool() const { |
|
|
explicit operator bool() const { |
|
|