Class TriggerFuture<T>

java.lang.Object
com.googlecode.objectify.cache.TriggerFuture<T>
All Implemented Interfaces:
Future<T>
Direct Known Subclasses:
TriggerSuccessFuture

public abstract class TriggerFuture<T>
extends Object
implements Future<T>

A Future wrapper that executes an abstract method with the result at some point after the data becomes available. A "best effort" is made to ensure execution, but it may be left untriggered until the end of a request.

Notification will happen ONCE:

  • After get() is called
  • When the future is done and isDone() is called
  • At the end of a request that has the AsyncCacheFilter enabled.

Use the AsyncCacheFilter for normal requests. For situations where a filter is not appropriate (ie, the remote api) be sure to call PendingFutures.completeAllPendingFutures() manually.

Note that if you are using this with Objectify, you probably want to use ObjectifyFilter.complete() rather than PendingFutures or AsyncCacheFilter static methods.

Author:
Jeff Schnitzer
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Future<T>
    Wrap the raw Future
  • Constructor Summary

    Constructors
    Constructor
    Description
    Wrap a normal Future
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    cancel​(boolean mayInterruptIfRunning)
     
    get()
     
    get​(long timeout, TimeUnit unit)
     
    boolean
     
    boolean
    This version also checks to see if we are done and we still need to call the trigger.
    protected abstract void
    This method will be called ONCE upon completion of the future, successful or not.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait