Groovy Documentation

kotka.gradle.utils
[Groovy] Class Delay

java.lang.Object
  kotka.gradle.utils.Delay

final class Delay

A Delay allows to delay a computation until a later point in the future. It is a well known concept from more functional oriented languages. For example in Scheme this construct is called a promise. This implementation is closely inspired by Clojure's delay.

Authors:
Meikel Brandmeyer


Constructor Summary
Delay(groovy.lang.Closure f)

Constructs a new Delay which will produce the result value of the provided Closure f.

 
Method Summary
java.lang.Object doForce()

Forces the computation to happen caching the result.

static java.lang.Object force(java.lang.Object o)

Forces the delayed compatution.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Constructor Detail

Delay

Delay(groovy.lang.Closure f)
Constructs a new Delay which will produce the result value of the provided Closure f.
Parameters:
f - the closure which captures the computation
Returns:
a new Delay


 
Method Detail

doForce

java.lang.Object doForce()
Forces the computation to happen caching the result. In particular any computation happens only once! In case an Exception was thrown during the execution of the computation the exception is rethrown on the current thread. This is a low-level function. You should use Delay.force instead.
Returns:
the result of the delayed computation.


force

static java.lang.Object force(java.lang.Object o)
Forces the delayed compatution. Acts as the identity in case the * given object is not a Delay. Should the produced value be another Delay forcing is continued recursively. Should an exception be thrown by the delayed computation it is rethrown to be handled by the calling code.
Parameters:
o - an arbitrary Object
Returns:
the delayed value in case o is a Delay, o itself otherwise


 

Groovy Documentation