Browse Source

Don't use atomic for WeakPtr reference count.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
4edd00d855
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      include/weakptr.hpp

+ 5
- 3
include/weakptr.hpp View File

@@ -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 {


Loading…
Cancel
Save