Skip to content

Instantly share code, notes, and snippets.

@na-ka-na
Created May 13, 2012 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save na-ka-na/2690759 to your computer and use it in GitHub Desktop.
Save na-ka-na/2690759 to your computer and use it in GitHub Desktop.
@lombok.Memoize
/*
@lombok.Memoize
final Number test(int a, Double b) {
return null;
}
*/
class Test{
@java.lang.SuppressWarnings("all")
private final java.util.concurrent.ConcurrentHashMap __lombok_test_c_0 = new java.util.concurrent.ConcurrentHashMap();
@java.lang.SuppressWarnings("all")
final Number test(int a, Double b) {
java.util.List l = java.util.Arrays.asList(a, b);
java.lang.Object[] lock = new java.lang.Object[0];
java.lang.Object[] ret = (java.lang.Object[])__lombok_test_c_0.putIfAbsent(l, lock);
if (ret == null) {
Number __lombok_calc = __lombok_test(a, b);
ret = new java.lang.Object[]{__lombok_calc};
__lombok_test_c_0.put(l, ret);
synchronized (lock) {
lock.notifyAll();
}
} else if (ret.length == 0) {
lock = ret;
synchronized (lock) {
while (ret.length == 0) {
try {
lock.wait();
} catch (InterruptedException e) {
;
}
ret = (java.lang.Object[])__lombok_test_c_0.get(l);
}
}
}
return (Number)ret[0];
}
private Number __lombok_test(int a, Double b) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment