org.hd.d.pg2k.test.dev
Class SimpleCacheTest.DataConcurrencyAccessMonitor
java.lang.Object
org.hd.d.pg2k.svrCore.datasource.SimpleExhibitPipelineFilter
org.hd.d.pg2k.test.dev.SimpleCacheTest.DataConcurrencyAccessMonitor
- All Implemented Interfaces:
- SimpleExhibitPipelineIF, BasicVarMgrInterface, SimpleVariablePipelineIF
- Enclosing class:
- SimpleCacheTest
static final class SimpleCacheTest.DataConcurrencyAccessMonitor
- extends SimpleExhibitPipelineFilter
Thread-safe monitor of data-read activity.
An instance of this class can be inserted into a pipeline
to record or modify data-read activity.
|
Field Summary |
private int |
blockedThreadsCount
Count of blocked thread in getRawData(). |
private boolean |
dontBlock
Once true, threads do not block in getRawFile(); volatile so as not to need the mutex. |
private java.lang.Object |
notifier
Used to notify/wake blocked threads. |
|
Method Summary |
private int |
getBlockedThreadsCount()
Get count of blocked thread in getRawData(); non-negative. |
void |
getRawFile(java.nio.ByteBuffer buf,
Name.ExhibitFull exhibitName,
int position,
boolean dontCache)
Intercept and block calls as if blocked waiting for disc access. |
(package private) void |
release()
Call this to release any waiting/blocked threads in getRawFile(). |
| Methods inherited from class org.hd.d.pg2k.svrCore.datasource.SimpleExhibitPipelineFilter |
destroy, getAllExhibitImmutableData, getAllExhibitProperties, getEventValue, getEventValues, getGenProps, getGenSecProps, getProperties, getStaticAttr, getStratum, getThumbnails, getVariable, getVariables, poll, setVariable, setVariables, syncVariables |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
dontBlock
private volatile boolean dontBlock
- Once true, threads do not block in getRawFile(); volatile so as not to need the mutex.
blockedThreadsCount
private int blockedThreadsCount
- Count of blocked thread in getRawData().
Must only be accessed under protection of the notifier mutex.
notifier
private final java.lang.Object notifier
- Used to notify/wake blocked threads.
SimpleCacheTest.DataConcurrencyAccessMonitor
SimpleCacheTest.DataConcurrencyAccessMonitor(SimpleExhibitPipelineIF upstream)
getBlockedThreadsCount
private int getBlockedThreadsCount()
- Get count of blocked thread in getRawData(); non-negative.
release
void release()
- Call this to release any waiting/blocked threads in getRawFile().
getRawFile
public void getRawFile(java.nio.ByteBuffer buf,
Name.ExhibitFull exhibitName,
int position,
boolean dontCache)
throws java.io.IOException
- Intercept and block calls as if blocked waiting for disc access.
- Specified by:
getRawFile in interface SimpleExhibitPipelineIF- Overrides:
getRawFile in class SimpleExhibitPipelineFilter
- Parameters:
buf - the buffer into which to read the data;
must be non-null, in put()able state,
and with remaining capacity of at least the requested number of bytesexhibitName - the full name of the exhibit to read from;
never null and must be syntactically validposition - position/index of first byte in exhibitFile to read;
non-negativedontCache - if true, this is a hint not to attempt to cache this
or displace anything from extant caches for this data
as it maqy for example be precaching or random activity;
by default callers should leave this false to allow cacheing
- Throws:
java.io.IOException - for requests that cannot be fulfilled because of
I/O restrictions or problems, such as link failure or
an upper bound on the length of a request
Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.