Interface ILcdLockDependent

All Known Implementing Classes:
TLcd2DBoundsIndexedModelList, TLcdAIXM51AbstractAIXMMessage, TLcdASTERIXFilteredModel, TLcdGML2AbstractFeatureCollection, TLcdGML31AbstractFeatureCollection, TLcdGML31DynamicFeatureCollection, TLcdGML31FeatureCollection, TLcdGML31Model, TLcdGML32AbstractFeatureCollection, TLcdGML32FeatureCollection, TLcdGML32Model, TLcdModelList, TLcdMultilevel2DBoundsIndexedModel, TLcdNetCDFFilteredModel

public interface ILcdLockDependent

Exposes lock dependencies to ensure that TLcdLockUtil locks all needed objects in the correct order. If an object implements this interface, TLcdLockUtil first locks all objects returned by getDependentObjects() before locking this object.

For example, suppose that model A wraps model B. Model A relies on its internal model B for read and write operations, but both model A and model B are also used externally, because they have been added to a view for example. If you read or write from model A, you must also lock B,because other objects may also access B. To make this transparent to users of model A, A can implement this interface and TLcdLockUtil takes care of locking all other required objects.

This is an example of how you can use this interface:

  public class MyModel extends ALcdModel implements ILcdLockDependent {

    // This model depends on the delegate model for read or write operations, but the delegate model may be accessed
    // externally as well.
    private final ILcdModel delegateModel;

    public MyModel(ILcdModel aDelegateModel) {
      delegateModel = aDelegateModel;
    }

    @Override
    public List<Object> getDependentObjects() {

      // This ensures that, when a read or write lock is taken on this model with TLcdLockUtil,
      // the delegate model is also locked, before the lock on this model is taken.
      return Collections.singletonList(delegateModel);
    }

    @Override
    public Enumeration elements() {
      return delegateModel.elements();
    }
  }

See this article for more information about the locking conventions in LuciadLightspeed.

Since:
2021.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the objects that must be locked along with this object.
  • Method Details

    • getDependentObjects

      List<Object> getDependentObjects()
      Returns the objects that must be locked along with this object. TLcdLockUtilfirst locks all objects returned by this method before locking this object.
      Returns:
      the objects that must be locked along with this object.