Interface PumpOpGrantManager

All Known Implementing Classes:
LimitGrantManager, LockGrantManager

public interface PumpOpGrantManager
Interface for managing allocation of grants to pump operations as they are performed. This allows managers to implement grant policies that control concurrency of pump ops. For example, to prevent water and carb from being used at the same time, the operations can leverage an exclusive lock grant so only the operation that owns the lock can be run. Similarly, to limit the number of pumps that can be run from a given board concurrently (such as when there are power constraints) a grant manager can be used to ensure that only the first N pumps get a grant.

Grant names can be added to pump ops via intents.xml. Grants can have a colon in the name where the string up to the colon is the grant type and the string after the colon is data provided to the corresponding grant manager. This allows grants to include limited data that the manager can operate on. For example, a power based grant manager may look for a power value after the colon.

The base TpourOp and VpourOp classes include a default grant called limit. This can be used by the LimitPumpOpGrantManager to restrict how many pumps can be run per board or per device.

Managers are called sequentially with the entire list of grants that the pump op requires. The manager must examine all grants and process those that it cares about. A manager must lock the resources associated with the grants if indicating that the grant was acquired. If any manager fails to acquire a grant, all previously successful acquisitions will be released. All requests for grants will be serialized. This ensures there will be no deadlocks, eliminates the need for complex transactional logic with distributed grants, and ensures that grant managers don't need to be reentrant.

Since:
1.0
Version:
2024-07-24
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Acquire the specified grants for the specified pump op.
    void
    Called to release any grants acquired by the specified pump op.
  • Method Details

    • acquireGrants

      boolean acquireGrants(PumpOp op)
      Acquire the specified grants for the specified pump op. If the grants can be acquired, any associated resources should be locked until released by calling releaseGrants() with the same pump op. Each registered manager will be called and if any one fails, all acquired grants up to that point will be released by a call to releaseGrants() . All calls are serialized so grant managers need not worry about concurrency or global deadlocks. If this manager does not manage any of the specified grants, it should still return true to indicate that no grants have been denied.
      Parameters:
      op - the pump operation containing the grants
      Returns:
      false if the grants could not be acquired
    • releaseGrants

      void releaseGrants(PumpOp op)
      Called to release any grants acquired by the specified pump op.
      Parameters:
      op - the op used to acquire grants