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:
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) |
/** | |
* 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; |
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(); | |
} | |
} | |
} |
I hereby claim:
To claim this, I am signing this object:
/* | |
Copyright 2012 Viktor Klang | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
import java.util.Arrays; | |
public class ThreadAwareExceptionTest { | |
static class ThreadAwareThread extends Thread { | |
Throwable entryPoint; | |
ThreadAwareThread(Runnable runnable) { | |
super(runnable); | |
} |
import io.dropwizard.Configuration; | |
import io.dropwizard.configuration.ConfigurationFactory; | |
import io.dropwizard.jackson.Jackson; | |
import io.dropwizard.jersey.DropwizardResourceConfig; | |
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider; | |
import io.dropwizard.logging.LoggingFactory; | |
import io.dropwizard.setup.Environment; | |
import java.io.File; | |
import java.io.FileNotFoundException; |
import io.dropwizard.Application; | |
import io.dropwizard.Configuration; | |
import io.dropwizard.cli.ServerCommand; | |
import io.dropwizard.lifecycle.ServerLifecycleListener; | |
import io.dropwizard.setup.Bootstrap; | |
import io.dropwizard.setup.Environment; | |
import io.dropwizard.testing.junit.ConfigOverride; | |
import java.util.Enumeration; |
/** | |
* A waiter where waiting threads can be interrupted (as opposed to awakened). | |
* | |
* @author Jonathan Halterman | |
*/ | |
public class InterruptableWaiter { | |
private final Sync sync = new Sync(); | |
private static final class Sync extends AbstractQueuedSynchronizer { | |
private static final long serialVersionUID = 4016766900138538852L; |
/** | |
* A circuit that accepts re-entrant {@link #open()} and {@link #close()} calls and ensures fairness | |
* when releasing {@link #await() waiting} threads. | |
* | |
* @author Jonathan Halterman | |
*/ | |
public class ReentrantCircuit { | |
private final Sync sync = new Sync(); | |
/** |