This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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(); | |
/** |
NewerOlder