This file contains hidden or 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
package hydra; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.locks.AbstractQueuedSynchronizer; | |
/** | |
* Taken mostly from the documentation of {@link AbstractQueuedSynchronizer} | |
*/ | |
public class BooleanLatch { | |
@SuppressWarnings("serial") |
This file contains hidden or 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 java.util.concurrent.Callable; | |
import java.util.concurrent.atomic.AtomicReference; | |
import javax.swing.SwingUtilities; | |
public class EventQueue { | |
private EventQueue() {} | |
public static void invokeAndWait(Runnable doRun) { |
This file contains hidden or 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 java.lang.reflect.InvocationTargetException; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class Exceptions { | |
private static Throwable toThrow; | |
private Exceptions() throws Throwable { | |
throw toThrow; | |
} | |
This file contains hidden or 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
class Args | |
def self.expect &proc | |
parser = self.new | |
parser.instance_eval &proc | |
return parser | |
end | |
attr_reader :positional | |
def [](name) | |
@args.fetch(name.to_s, NullMarshaler).value |
This file contains hidden or 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 class PredicatedCursor<T> implements Cursor<T> { | |
public interface Predicate<T> { | |
boolean apply(T element); | |
} | |
private final Predicate<? super T> predicate; | |
private final Cursor<T> delegate; | |
public PredicatedCursor(Cursor<T> delegate, Predicate<? super T> predicate) { | |
Cursor<T> current = delegate; |
This file contains hidden or 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
(function() { | |
var origDefine = define; | |
function redefine(name, definitions) { | |
return function (prereqs, definition) { | |
if (arguments.length > 2) { | |
throw new Error('Cannot have more than two arguments to define in ' + name); | |
} else if (arguments.length === 1) { | |
definition = prereqs; | |
prereqs = []; |
This file contains hidden or 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
package common; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class Global { | |
private static boolean inTests; | |
private static final Map<Class<?>, Object> globals = new HashMap<Class<?>, Object>(); | |
private Global() {} |
This file contains hidden or 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
class Entity | |
applyEvent: (event, args) -> | |
@[Entity._handler event] args... | |
@_handler: (name) -> "on_#{name}" | |
@event: (name, handler) -> | |
@::[name] = -> | |
@applyEvent name, arguments | |
@::[Entity._handler name] = handler |
NewerOlder