コード例 #1
0
ファイル: Memoizer.java プロジェクト: notfb/SLA
 public V compute(final A arg) throws InterruptedException {
   while (true) {
     Future<V> f = cache.get(arg);
     if (f == null) {
       Callable<V> eval =
           new Callable<V>() {
             public V call() throws InterruptedException {
               return c.compute(arg);
             }
           };
       FutureTask<V> ft = new FutureTask<V>(eval);
       f = cache.putIfAbsent(hash.compute(arg), ft);
       if (f == null) {
         f = ft;
         ft.run();
       }
     }
     try {
       return f.get();
     } catch (CancellationException e) {
       cache.remove(arg, f);
     } catch (ExecutionException e) {
       throw LaunderThrowable.launderThrowable(e.getCause());
     }
   }
 }
コード例 #2
0
ファイル: TimedRun2.java プロジェクト: hiprice/redis-spring
 void rethrow() {
   if (t != null) throw LaunderThrowable.launderThrowable(t);
 }