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
#include <common.hpp>
#include <atomic>


namespace rack {
@@ -8,7 +7,7 @@ namespace rack {

struct WeakHandle {
void* ptr;
std::atomic<size_t> count{0};
size_t count = 0;
WeakHandle(void* ptr) : ptr(ptr) {}
};

@@ -89,10 +88,13 @@ struct WeakPtr {
return nullptr;
return reinterpret_cast<T*>(weakHandle->ptr);
}
T* operator->() const {
return get();
}
T& operator*() const {
return *get();
}
T* operator->() const {
operator T*() const {
return get();
}
explicit operator bool() const {


Loading…
Cancel
Save