Class ContextStateFutureImpl<T>

  • All Implemented Interfaces:
    StateFuture<T>, InternalStateFuture<T>

    public class ContextStateFutureImpl<T>
    extends StateFutureImpl<T>
    A state future that holds the RecordContext and maintains the reference count of it. The reason why we maintain the reference here is that the ContextStateFutureImpl can be created multiple times since user may chain their code wildly, some of which are only for internal usage (See StateFutureImpl). So maintaining reference counting by the lifecycle of state future is relatively simple and less error-prone.

    Reference counting added on RecordContext follows:

  • 1. +1 when this future created.
  • 2. -1 when future completed.
  • 3. +1 when callback registered.
  • 4. -1 when callback finished.
  • Please refer to ContextStateFutureImplTest where the reference counting is carefully tested.