diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DataCache.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DataCache.java deleted file mode 100644 index 113fb29f990..00000000000 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DataCache.java +++ /dev/null @@ -1,200 +0,0 @@ -package org.eclipse.cdt.dsf.concurrent; - -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ - -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.Executor; - -import org.eclipse.cdt.dsf.internal.DsfPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -/** - * A general purpose cache, which caches the result of a single request. - * Sub classes need to implement {@link #retrieve(DataRequestMonitor)} to fetch - * data from the data source. Clients are responsible for calling - * {@link #disable()} and {@link #reset()} to manage the state of the cache in - * response to events from the data source. - *
- * This cache requires an executor to use. The executor is used to synchronize - * access to the cache state and data. - *
- * @since 2.1 - */ -@ConfinedToDsfExecutor("fExecutor") -public abstract class DataCachetrue
if the cache is currently valid. I.e.
- * whether the cache can return a value immediately without first
- * retrieving it from the data source.
- */
- public boolean isValid() {
- return fValid;
- }
-
- /**
- * Returns true
if the cache is currently waiting for data
- * from the data source.
- */
- public boolean isPending() {
- return fRm != null;
- }
-
- /**
- * Returns the current data value held by this cache. Clients should first
- * call isValid() to determine if the data is up to date.
- */
- public V getData() {
- return fData;
- }
-
- /**
- * Returns the status of the source request held by this cache. Clients
- * should first call isValid() to determine if the data is up to date.
- */
- public IStatus getStatus() {
- return fStatus;
- }
-
- /**
- * Request data from the cache. The cache is valid, it will complete the
- * request immediately, otherwise data will first be retrieved from the
- * source.
- * @param req
- */
- public void request(final DataRequestMonitornull
and an error
- * status with code {@link IDsfStatusConstants#INVALID_STATE}.
- *
- * @see #reset(Object, IStatus)
- */
- public void reset() {
- reset(null, new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Cache reset", null)); //$NON-NLS-1$
- }
-
- /**
- * Resets the cache with given data and status. Resetting the cache
- * forces the cache to be invalid and cancels any current pending requests
- * from data source.
- * - * This method should be called when the data source has issued an event - * indicating that the source data has changed but data may still be - * retrieved. Clients may need to re-request data following cache reset. - *
- * @param data The data that should be returned to any clients currently - * waiting for cache data. - * @status The status that should be returned to any clients currently - * waiting for cache data. - */ - public void reset(V data, IStatus status) { - fValid = false; - if (fRm != null) { - fRm.cancel(); - fRm = null; - } - set(data, status); - } - - /** - * Disables the cache with a data valuenull
and an error
- * status with code {@link IDsfStatusConstants#INVALID_STATE}.
- *
- * @see #disable(Object, IStatus)
- */
- public void disable() {
- disable(null, new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Cache disable", null)); //$NON-NLS-1$
- }
-
- /**
- * Resets the cache then disables it. When a cache is disabled it means
- * that it is valid and requests to the data source will not be sent.
- * - * This method should be called when the data source has issued an event - * indicating that the source data has changed and future requests for - * data will return the given data and status. Once the source data - * becomes available again, clients should call {@link #reset()}. - *
- * @param data The data that should be returned to any clients waiting for - * cache data and for clients requesting data until the cache is reset again. - * @status The status that should be returned to any clients waiting for - * cache data and for clients requesting data until the cache is reset again. - * - * @see #reset(Object, IStatus) - */ - public void disable(V data, IStatus status) { - reset(data, status); - fValid = true; - } -}