@Override
 public void test(final Store<String, Object> store) {
   IntegerRange _upTo = new IntegerRange(1, 50);
   for (final Integer j : _upTo) {
     store.putSync(("" + j), ("e" + j));
   }
   final Operation<List<Success>> _function =
       new Operation<List<Success>>() {
         @Override
         public void apply(final ValueCallback<List<Success>> cb) {
           final Aggregator<Success> col = Async.<Success>collect(50, cb);
           IntegerRange _upTo = new IntegerRange(1, 50);
           for (final Integer i : _upTo) {
             new Thread() {
               @Override
               public void run() {
                 store.getSync(("" + i));
                 ValueCallback<Success> _createCallback = col.createCallback();
                 _createCallback.onSuccess(Success.INSTANCE);
               }
             }.start();
           }
         }
       };
   Async.<List<Success>>waitFor(_function);
 }
예제 #2
0
  @Override
  public V getSync(final K key) {
    if (ENABLE_LOG) {
      System.out.println(this + ": Sync get " + key);
    }
    final V value =
        Async.waitFor(
            new Operation<V>() {

              @Override
              public void apply(final ValueCallback<V> callback) {
                scheduled.offer(new EntryData<K, V>(key, callback));
                executeGetsAfterDelay();
              }
            });
    if (ENABLE_LOG) {
      System.out.println(this + ": Successful sync get " + key);
    }
    return value;
  }