org.das2.qds.ReferenceCache

Provide a cache of datasets that are in memory, so that the same data is not loaded twice. This first implementation uses WeakReferences, so that this cache need not be emptied, but we will avoid the situation where the same data is loaded twice.


getDataSetOrLock

getDataSetOrLock( String uri, ProgressMonitor monitor ) → ReferenceCacheEntry

Get a ReferenceCacheEntry for the URI, which will indicate the thread which has been designated as the load thread.


rcent= ReferenceCache.getInstance().getDataSetOrLock( this.tsb.getURI(), mon);
if ( !rcent.shouldILoad( Thread.currentThread() ) ) { 
   QDataSet result= rcent.park( mon );

Be sure to use try/finally when using this cache!

Parameters

uri - the URI to load.
monitor - to monitor the load.

Returns:

the ReferenceCacheEntry

search for examples view on GitHub view source


park

park( org.das2.qds.ReferenceCache.ReferenceCacheEntry ent, ProgressMonitor monitor ) → void

park this thread until the other guy has finished loading.

Parameters

ent -
monitor - the monitor of the load.

Returns:

void (returns nothing)

search for examples view on GitHub view source


putDataSet

putDataSet( String uri, QDataSet ds ) → void

put the dataset into the ReferenceCache. If it is mutable, then a copy is made.

Parameters

uri -
ds -

Returns:

void (returns nothing)

search for examples view on GitHub view source


tidy

tidy( ) → void

remove all the entries that have been garbage collected.

Returns:

void (returns nothing)

search for examples view on GitHub view source