I hereby claim:
- I am jhalterman on github.
- I am jhalterman (https://keybase.io/jhalterman) on keybase.
- I have a public key whose fingerprint is 43F6 97A7 C494 AD19 CFCA 48F4 489D 4D97 977C 14CE
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
public static <T> T getWithDcl(Supplier<T> supplier, Supplier<T> factory, Object mutex) { | |
T object = supplier.get(); | |
if (object == null) { | |
synchronized (mutex) { | |
object = supplier.get(); | |
if (object == null) { | |
object = factory.get(); | |
} | |
} | |
} |
/** | |
* An exponentially weighted moving average implementation that decays based on the elapsed time since the last update, | |
* approximating a time windowed moving average. | |
*/ | |
public class MovingAverage { | |
private final long windowNanos; | |
// Mutable state | |
private volatile long lastNanos; | |
private volatile double average; |
package net.jodah.cancellablefuture | |
import java.util.concurrent.atomic.AtomicBoolean | |
import scala.concurrent._ | |
import scala.concurrent.duration.Duration | |
import scala.util.{Failure, Success, Try} | |
object CancellableFuture { | |
def apply[T](body: => T)(implicit executor: ExecutionContext): CancellableFuture[T] = new CancellableFuture(body) |