mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 23:15:24 +02:00
Bug 310345 - [concurrent] Asynchronous Cache Programming Model (ACPM) utilities for DSF. The reset() method should null out the data reference and set status to INVALID_STATUS. The former is particularly important since we otherwise hold the memory hostage. Functionally there's no difference since neither the data nor status can be queried when in invalid state.
This commit is contained in:
parent
2cd5b59772
commit
197f94773b
1 changed files with 31 additions and 23 deletions
|
@ -233,36 +233,44 @@ public abstract class AbstractCache<V> implements ICache<V> {
|
||||||
|
|
||||||
return canceled;
|
return canceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the cache with a data value <code>null</code> and an error
|
* Resets the cache, setting the data to null and the status to
|
||||||
* status with code {@link IDsfStatusConstants#INVALID_STATE}.
|
* INVALID_STATUS. When in the invalid state, neither the data nor the
|
||||||
*
|
* status can be queried.
|
||||||
* @see #reset(Object, IStatus)
|
*/
|
||||||
*/
|
|
||||||
protected void reset() {
|
protected void reset() {
|
||||||
if (!fValid) {
|
if (!fValid) {
|
||||||
throw new IllegalStateException("Cache is not valid. Cache can be reset only when it's in a valid state"); //$NON-NLS-1$
|
throw new IllegalStateException("Cache is not valid. Cache can be reset only when it's in a valid state"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
fValid = false;
|
fValid = false;
|
||||||
|
fData = null;
|
||||||
|
fStatus = INVALID_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the cache then disables it. When a cache is disabled it means
|
* Moves the cache to the valid state with the given data and status. Note
|
||||||
* that it is valid and requests to the data source will not be sent.
|
* that data may be null and status may be an error status. 'Valid' simply
|
||||||
* <p>
|
* means that our data is not stale. In other words, if the request to the
|
||||||
* This method should be called when the data source has issued an event
|
* source encounters an error, the cache object becomes valid all the same.
|
||||||
* indicating that the source data has changed and future requests for
|
* The status indicates what error was encountered.
|
||||||
* data will return the given data and status. Once the source data
|
*
|
||||||
* becomes available again, clients should call {@link #reset()}.
|
* <p>
|
||||||
* </p>
|
* This method is called internally, typically in response to having
|
||||||
* @param data The data that should be returned to any clients waiting for
|
* obtained the result from the asynchronous request to the source. The
|
||||||
* cache data and for clients requesting data until the cache is reset again.
|
* data/status will remain valid until the cache object receives an event
|
||||||
* @status The status that should be returned to any clients waiting for
|
* notification from the source indicating otherwise.
|
||||||
* cache data and for clients requesting data until the cache is reset again.
|
*
|
||||||
*
|
* @param data
|
||||||
* @see #reset(Object, IStatus)
|
* The data that should be returned to any clients waiting for
|
||||||
*/
|
* cache data and for clients requesting data until the cache is
|
||||||
|
* invalidated.
|
||||||
|
* @status The status that should be returned to any clients waiting for
|
||||||
|
* cache data and for clients requesting data until the cache is
|
||||||
|
* invalidated
|
||||||
|
*
|
||||||
|
* @see #reset(Object, IStatus)
|
||||||
|
*/
|
||||||
protected void set(V data, IStatus status) {
|
protected void set(V data, IStatus status) {
|
||||||
assert fExecutor.getDsfExecutor().isInExecutorThread();
|
assert fExecutor.getDsfExecutor().isInExecutorThread();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue