Plexus v0.13.1

com.phoenixst.collections
Class RunnableReaper

java.lang.Object
  extended by com.phoenixst.collections.RunnableReaper
All Implemented Interfaces:
Reaper, Runnable

public class RunnableReaper
extends Object
implements Runnable, Reaper

A Runnable which reaps Reapables.

Since:
1.0
Version:
$Revision: 1.1 $
Author:
Ray A. Conner

Field Summary
static Reaper DEFAULT_INSTANCE
          A single default Reaper which to be used when a structure doesn't mind sharing the reaping thread with other things.
 
Constructor Summary
RunnableReaper()
          Creates a new RunnableReaper which sleeps for 0.1 seconds after emptying its internal ReferenceQueue of waiting References and notifying the corresponding Reapables.
RunnableReaper(long sleepTime)
          Creates a new RunnableReaper which sleeps for the specified number of milliseconds after emptying its internal ReferenceQueue of waiting References and notifying the corresponding Reapables.
 
Method Summary
 Reference createReference(Reapable reapable, Object referent)
          Creates and returns a Reference for the given arguments.
static Reaper getInstance(String name)
          Creates a new RunnableReaper which sleeps for 0.1 seconds after emptying its internal ReferenceQueue of waiting References and notifying the corresponding Reapables.
static Reaper getInstance(String name, long sleepTime, int threadPriority)
          Creates a new RunnableReaper which sleeps for the specified number of milliseconds after emptying its internal ReferenceQueue of waiting References and notifying the corresponding Reapables.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INSTANCE

public static final Reaper DEFAULT_INSTANCE
A single default Reaper which to be used when a structure doesn't mind sharing the reaping thread with other things.

Constructor Detail

RunnableReaper

public RunnableReaper()
Creates a new RunnableReaper which sleeps for 0.1 seconds after emptying its internal ReferenceQueue of waiting References and notifying the corresponding Reapables. It is up to the user to create a thread to run this Reaper; alternatively, one of the static factory methods can be used.


RunnableReaper

public RunnableReaper(long sleepTime)
Creates a new RunnableReaper which sleeps for the specified number of milliseconds after emptying its internal ReferenceQueue of waiting References and notifying the corresponding Reapables. It is up to the user to create a thread to run this Reaper; alternatively, one of the static factory methods can be used.

Method Detail

getInstance

public static Reaper getInstance(String name)
Creates a new RunnableReaper which sleeps for 0.1 seconds after emptying its internal ReferenceQueue of waiting References and notifying the corresponding Reapables. A new thread of minimum priority to run the RunnableReaper is also created and started by this method.


getInstance

public static Reaper getInstance(String name,
                                 long sleepTime,
                                 int threadPriority)
Creates a new RunnableReaper which sleeps for the specified number of milliseconds after emptying its internal ReferenceQueue of waiting References and notifying the corresponding Reapables. A new thread of the specified priority to run the RunnableReaper is also created and started by this method.


createReference

public Reference createReference(Reapable reapable,
                                 Object referent)
Description copied from interface: Reaper
Creates and returns a Reference for the given arguments. Sometime after the Reference is reclaimed by the garbage collector, the argument's Reapable.reap() method will be called. Please note that there is typically no guarantee that this method will ever be called, so this mechanism should not be relied upon as a replacement for a try/finally block.

Implementations should never return PhantomReferences if the referent needs to be retrievable while it is still referencable through other paths, or if the Reference.clear() is not guaranteed to be called.

Specified by:
createReference in interface Reaper

run

public void run()
Specified by:
run in interface Runnable

Plexus v0.13.1

See the Plexus project home, hosted by SourceForge.
Copyright ? 1994-2006, by Phoenix Software Technologists, Inc. and others. All Rights Reserved. Use is subject to license terms.