コード例 #1
0
 public void run() {
   sp1.addListener(key, this);
   long stamp = System.nanoTime();
   for (int i = 0; i < COUNT; i++) sp1.out(key, Boolean.TRUE);
   long stamp2 = System.nanoTime();
   t1.add(stamp2 - stamp);
   System.err.println("Perform. " + key + " out: " + (stamp2 - stamp) / 1000000);
 }
コード例 #2
0
ファイル: Connector.java プロジェクト: netmask/jPOS
  public void setConfiguration(Configuration cfg) {
    if (this.cfg != null) sp.removeListener(from, this);

    this.cfg = cfg;
    from = cfg.get("from");
    to = cfg.get("to");

    sp.addListener(from, this);
  }
コード例 #3
0
  @Ignore("Remove it when TSpace can pass it")
  @Test
  public void testStolenEntryAtNotify() throws Throwable {
    int size = 10;
    final ExecutorService es =
        new ThreadPoolExecutor(
            size * 2, Integer.MAX_VALUE, 30, TimeUnit.SECONDS, new SynchronousQueue());
    ((ThreadPoolExecutor) es).prestartAllCoreThreads();

    for (int i = 0; i < size; i++) es.execute(new WriteSpaceWithNotifyReadTask("WriteTask-" + i));

    // Threads which may stole entries
    for (int i = 0; i < size; i++) es.execute(new ReadSpaceTask("WriteTask-" + i));

    assertNull("Detected stolen entry at notify", sp2.in("lost-entry", 200));

    es.shutdownNow();
    //        es.awaitTermination(5, TimeUnit.SECONDS);
  }
コード例 #4
0
ファイル: Connector.java プロジェクト: netmask/jPOS
 public void notify(Object key, Object value) {
   Object o = sp.inp(key);
   if (o != null) sp.out(to, o);
 }
コード例 #5
0
ファイル: Connector.java プロジェクト: netmask/jPOS
 public Connector(String from, String to) {
   this();
   this.from = from;
   this.to = to;
   sp.addListener(from, this);
 }
コード例 #6
0
 public void notify(Object key, Object value) {
   if ((++count % 100) == 0) {
     sp2.out((String) key, value);
   }
 }