How is storing unintptrs in a map different from say java.util.WeakHashMap?
The data pointed to by the uintptrs can at any given time have been
reclaimed by the GC much the same as weak references in Java.

I am not saying you are using it the same way as one would normally use
weak references in other languages.

fre 28 sep. 2018 kl 14:17 skrev Peter Mogensen <a...@one.com>:

>
>
> On 09/28/2018 02:04 PM, Robert Engels wrote:
> > This is in no way similar to weak references in Java. Weak references
> > are safe and appropriate for many caching data structures. The code idea
> > presented here is not related.
>
> Correct.
> I've used weak references in other languages (not Java) to, say, prevent
> leaks due to reference cycles.
>
> This is not that.
> My idea could maybe be restated simpler as having a huge double-linked
> list of sync.Pool objects and using wanting to supplement it by a map
> index, but avoiding storing pointers in the map.
>
> I don't think I've seen any argument that it's technically impossible by
> now, but maybe there's better ways to do it ... maybe even write the
> index manually instead of using the build in map.
>
> I think the warning about this being "catastrophically unsafe" forgets
> that these objects will be kept with proper pointers in a separate data
> structure and the map was only intended as an index.
> It was never the intention to let an uintptr be the only remaining
> reference to the objects. There will of course, always be a need for
> keeping proper pointers in a datastructure (like a list) to be able to
> do proper Put() on the objects before the map reference is lost.
>
> Anyway... I think I've found a more efficient way using integer slice
> indexes instead of uintptr.
>
> Thanks for input
>
> /Peter
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to