--
guava-...@googlegroups.com
Project site: http://guava-libraries.googlecode.com
This group: http://groups.google.com/group/guava-discuss
This list is for general discussion.
To report an issue: http://code.google.com/p/guava-libraries/issues/entry
To get help: http://stackoverflow.com/questions/ask (use the tag "guava")
It lacks a couple fixes for environments where class unloading is used
and where starting a thread is impossible, but I seem to recall that
problems remained with at least one of those cases, so, especially if
you don't need either support, you might prefer the older version
without the complexity.
class NativeMemoryReferenceextends PhantomReference<NativeMemory> {final int address;NativeMemoryReference(NativeMemory referent,ReferenceQueue<NativeMemory> rq) {super(referent, rq);address = referent.address;}}public class NativeMemoryManager {private static final Set<Reference<?>> refs= Collections.synchronizedSet(new HashSet<Reference<?>>());private static final ReferenceQueue<NativeMemory> rq= new ReferenceQueue<NativeMemory>();public static NativeMemory allocate() {NativeMemory nm = new NativeMemory();refs.add(new NativeMemoryReference(nm, rq));cleanUp();return nm;}private static void cleanUp() {NativeMemoryReference ref;while ((ref = (NativeMemoryReference) rq.poll()) != null) {NativeMemory.free(ref.address);refs.remove(ref);}}}
public class NativeMemoryManager {private static final Set<Reference<?>> refs= Collections.synchronizedSet(new HashSet<Reference<?>>());private static final FinalizableReferenceQueue frq= new FinalizableReferenceQueue();public static NativeMemory allocate() {NativeMemory nm = new NativeMemory();final int address = nm.address;refs.add(new FinalizablePhantomReference<NativeMemory>(nm, frq) {public void finalizeReferent() {NativeMemory.free(address);refs.remove(this);}});return nm;}}
Yeah; if you're convinced you have a good reason to use it, I'd probably just copy it. I don't think it's a generally good enough idea that we should keep it.
Does this mean you plan on resolving issues with multiple threads and explicit shutdown...?
--
All I care about is the ability to reload web applications or load different webapps with different versions of Guice into the same web container. Last I checked, FRQ had problems with this.
I don't personally need multiple threads, but as previously mentioned, you could solve both problems by allowing users to specify an Executor. Is there a downside to this?