Knowing if WeakReference::Master is Referencing Pointers


#1

Hi Jules,

Would you mind adding a method to WeakReference::Master for knowing if it has an initialised SharedRef or not?

ie:
Somewhere in class WeakReference::Master:

        bool hasSharedReferences() const { return sharedPointer != nullptr; }

#2

…why…? Can’t think of a use-case for that. Feels wrong to me.


#3

In the scope of JUCE, I understand and agree…

With a custom multi-threaded rendering-style OpenGL component system, it’s fairly difficult to juggle weak references with such components that need to be copied to the rendering thread (or anything reference-counted that happens to be dangling)…

Its use case is debugging (for the most part); figured I wouldn’t be the only one who could need it!


#4

Well, that actually won’t actually be correct anyway - that shared pointer is created, but never destroyed, so this could give a false positive.