Examples of AutoResetEvent


Examples of com.bj58.spat.gaea.client.utility.AutoResetEvent

    public byte[] receive(int sessionId, int queueLen) throws IOException, TimeoutException, Exception {
        WindowData wd = WaitWindows.get(sessionId);
        if (wd == null) {
            throw new Exception("Need invoke 'registerRec' method before invoke 'receive' method!");
        }
        AutoResetEvent event = wd.getEvent();
        int timeout = getReadTimeout(socketConfig.getReceiveTimeout(), queueLen);
        if (!event.waitOne(timeout)) {
            throw new TimeoutException("Receive data timeout or error!timeout:" + timeout + "ms,queue length:" + queueLen);
        }
        byte[] data = wd.getData();
        int offset = SFPStruct.Version;
        int len = ByteConverter.bytesToIntLittleEndian(data, offset);
View Full Code Here

Examples of com.bj58.spat.gaea.client.utility.AutoResetEvent

        }
        return data;
    }

    public void registerRec(int sessionId) {
        AutoResetEvent event = new AutoResetEvent();
        WindowData wd = new WindowData(event);
        WaitWindows.put(sessionId, wd);
    }
View Full Code Here

Examples of com.bj58.spat.gaea.client.utility.AutoResetEvent

*/
public class AutoResetEventTest {

  @Test
  public void testSet() throws InterruptedException {
    final AutoResetEvent event = new AutoResetEvent();
    Thread th = new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Logger.getLogger(AutoResetEventTest.class.getName()).log(Level.SEVERE, null, ex);
        }
        event.set();
        System.out.println("send set signal!");
      }
    });
    th.run();
    System.out.println("start wait!");
    event.waitOne(10000);
    System.out.println("end wait!");
  }
View Full Code Here

Examples of com.bj58.spat.gaea.client.utility.AutoResetEvent

    System.out.println("end wait!");
  }

  @Test
  public void testWaitOne() throws Exception {
    final AutoResetEvent event = new AutoResetEvent();
    event.set();
    event.set();
    System.out.println("stime:" + System.currentTimeMillis());
    event.waitOne(10000);
    event.waitOne(10000);
    event.waitOne(10000);
    event.waitOne(10000);
    System.out.println("time:" + System.currentTimeMillis());
  }
View Full Code Here

Examples of com.bj58.spat.gaea.client.utility.AutoResetEvent

*/
public class AutoResetEventTest {

  @Test
  public void testSet() throws InterruptedException {
    final AutoResetEvent event = new AutoResetEvent();
    Thread th = new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
          Logger.getLogger(AutoResetEventTest.class.getName()).log(Level.SEVERE, null, ex);
        }
        event.set();
        System.out.println("send set signal!");
      }
    });
    th.run();
    System.out.println("start wait!");
    event.waitOne(10000);
    System.out.println("end wait!");
  }
View Full Code Here

Examples of com.bj58.spat.gaea.client.utility.AutoResetEvent

    System.out.println("end wait!");
  }

  @Test
  public void testWaitOne() throws Exception {
    final AutoResetEvent event = new AutoResetEvent();
    event.set();
    event.set();
    System.out.println("stime:" + System.currentTimeMillis());
    event.waitOne(10000);
    event.waitOne(10000);
    event.waitOne(10000);
    event.waitOne(10000);
    System.out.println("time:" + System.currentTimeMillis());
  }
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.sim.events.AutoResetEvent

    IBitmap[] bitmaps = new IBitmap[textureIds.length];
    final AssetTexture[] result = new AssetTexture[1];
    for(int i=0; i < textureIds.length; i++)
    {

      AutoResetEvent textureDone = new AutoResetEvent(false);
      //Download the texture image
      Client.assets.RequestImage(textureIds[i], TextureDownloadCallback(result, textureDone));
      //wait for 1 min
      textureDone.waitOne(60 * 1000);
      if(result[0] != null)
      {
        //Decode the jpeg2000 image
        IOpenJPEG openJpeg = OpenJPEGFactory.getIntance();
        bitmaps[i] = openJpeg.DecodeToIBitMap(result[0].AssetData);
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.sim.events.AutoResetEvent

      else
        return null;
    }
    else
    { // Mesh
      final AutoResetEvent gotMesh = new AutoResetEvent(false);
      final FacetedMesh[] tmpMesh = new FacetedMesh[1]
      client.assets.RequestMesh(prim.Sculpt.SculptTexture, new MethodDelegate<Void, MeshDownloadCallbackArgs>()
          {
        public Void execute(MeshDownloadCallbackArgs e) {
          if (!e.isSuccess() || !FacetedMesh.TryDecodeFromAsset(prim, e.getAssetMesh(), MeshRenderDetail, tmpMesh))
          {
            JLogger.warn("Failed to fetch or decode the mesh asset");
          }
          gotMesh.set();               
          return null;
        }
          });
      mesh =  tmpMesh[0];
      gotMesh.waitOne(20 * 1000);
    }
    return mesh;
      }
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.sim.events.AutoResetEvent

  /// Blocking method to populate the Wearables dictionary
  /// </summary>
  /// <returns>True on success, otherwise false</returns>
  boolean GetAgentWearables() throws InterruptedException
  {
    final AutoResetEvent wearablesEvent = new AutoResetEvent(false);
    EventObserver<AgentWearablesReplyEventArgs> wearablesCallback =
        new EventObserver<AgentWearablesReplyEventArgs>()
        {
      @Override
      public void handleEvent(Observable s,
          AgentWearablesReplyEventArgs e)
      {
        wearablesEvent.set();                     
      }
        };

        this.registerOnAgentWearablesReply(wearablesCallback);     
        RequestAgentWearables();
        boolean success = wearablesEvent.waitOne(WEARABLE_TIMEOUT);
        this.unregisterOnAgentWearablesReply(wearablesCallback);
        return success;
  }
View Full Code Here

Examples of com.ngt.jopenmetaverse.shared.sim.events.AutoResetEvent

  /// Blocking method to populate the Textures array with cached bakes
  /// </summary>
  /// <returns>True on success, otherwise false</returns>
  boolean GetCachedBakes() throws InterruptedException
  {
    final AutoResetEvent cacheCheckEvent = new AutoResetEvent(false);
    EventObserver<AgentCachedBakesReplyEventArgs> cacheCallback =
        new EventObserver<AgentCachedBakesReplyEventArgs>()
        {
      @Override
      public void handleEvent(Observable s,
          AgentCachedBakesReplyEventArgs e) {
        cacheCheckEvent.set();                     
      }
        };

        this.registerOnCachedBakesReply(cacheCallback);

        RequestCachedBakes();

        boolean success = cacheCheckEvent.waitOne(WEARABLE_TIMEOUT);
        this.unregisterOnCachedBakesReply(cacheCallback);

        return success;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.