// // WeakReference+Owning.hpp // react-native-nitro // // Created by Marc Rousavy on 23.06.24. // #pragma once #include "BorrowingReference.hpp" namespace margelo::nitro { template WeakReference::WeakReference(const BorrowingReference& ref) { _value = ref._value; _state = ref._state; _state->weakRefCount++; } template BorrowingReference WeakReference::lock() const { std::unique_lock lock(_state->mutex); if (_state->isDeleted) { // return nullptr return BorrowingReference(); } return BorrowingReference(*this); } } // namespace margelo::nitro