示例#1
1
  public void unregisterKeyStroke(KeyStroke ks, JComponent c) {

    // component may have already been removed from the hierarchy, we
    // need to look up the container using the componentKeyStrokeMap.

    ComponentKeyStrokePair ckp = new ComponentKeyStrokePair(c, ks);

    Container topContainer = componentKeyStrokeMap.get(ckp);

    if (topContainer == null) { // never heard of this pairing, so bail
      return;
    }

    Hashtable keyMap = containerMap.get(topContainer);
    if (keyMap == null) { // this should never happen, but I'm being safe
      Thread.dumpStack();
      return;
    }

    Object tmp = keyMap.get(ks);
    if (tmp == null) { // this should never happen, but I'm being safe
      Thread.dumpStack();
      return;
    }

    if (tmp instanceof JComponent && tmp == c) {
      keyMap.remove(ks); // remove the KeyStroke from the Map
      // System.out.println("removed a stroke" + ks);
    } else if (tmp
        instanceof Vector) { // this means there is more than one component reg for this key
      Vector v = (Vector) tmp;
      v.removeElement(c);
      if (v.isEmpty()) {
        keyMap.remove(ks); // remove the KeyStroke from the Map
        // System.out.println("removed a ks vector");
      }
    }

    if (keyMap.isEmpty()) { // if no more bindings in this table
      containerMap.remove(topContainer); // remove table to enable GC
      // System.out.println("removed a container");
    }

    componentKeyStrokeMap.remove(ckp);

    // Check for EmbeddedFrame case, they know how to process accelerators even
    // when focus is not in Java
    if (topContainer instanceof EmbeddedFrame) {
      ((EmbeddedFrame) topContainer).unregisterAccelerator(ks);
    }
  }
示例#2
1
 @Override
 public Object dataGetStruct() {
   // for investigating and eliminating code that causes JavaObject to live
   if (DEBUG) Thread.dumpStack();
   lazyJavaObject();
   return javaObject;
 }
示例#3
1
 /**
  * Gets the location of a shader attribute.<br>
  * Uses either the cached value {@link #getCachedAttribLocation(String)} if valid, or the GLSL
  * queried via {@link GL2ES2#glGetAttribLocation(int, String)}.<br>
  * The location will be cached.
  *
  * @return -1 if there is no such attribute available, otherwise >= 0
  * @throws GLException if no program is attached
  * @throws GLException if the program is not linked and no location was cached.
  * @see #getCachedAttribLocation(String)
  * @see #bindAttribLocation(GL2ES2, int, GLArrayData)
  * @see #bindAttribLocation(GL2ES2, int, String)
  * @see GL2ES2#glGetAttribLocation(int, String)
  */
 public int getAttribLocation(GL2ES2 gl, String name) {
   if (null == shaderProgram) throw new GLException("No program is attached");
   int location = getCachedAttribLocation(name);
   if (0 > location) {
     if (!shaderProgram.linked()) throw new GLException("Program is not linked");
     location = gl.glGetAttribLocation(shaderProgram.program(), name);
     if (0 <= location) {
       Integer idx = new Integer(location);
       activeAttribLocationMap.put(name, idx);
       if (DEBUG) {
         System.err.println("ShaderState: glGetAttribLocation: " + name + ", loc: " + location);
       }
     } else if (verbose) {
       System.err.println(
           "ShaderState: glGetAttribLocation failed, no location for: "
               + name
               + ", loc: "
               + location);
       if (DEBUG) {
         Thread.dumpStack();
       }
     }
   }
   return location;
 }
示例#4
1
    @Override
    public void releaseSharedResource(SharedResourceRunner.Resource shared) {
      SharedResource sr = (SharedResource) shared;
      if (DEBUG) {
        System.err.println("Shutdown Shared:");
        System.err.println("Device  : " + sr.device);
        System.err.println("Screen  : " + sr.screen);
        System.err.println("Drawable: " + sr.drawable);
        System.err.println("CTX     : " + sr.context);
        Thread.dumpStack();
      }

      if (null != sr.context) {
        // may cause JVM SIGSEGV, or freeze (ATI fglrx 3-6-beta2 32on64 shared ctx):
        sr.context.destroy(); // will also pull the dummy MutableSurface
        sr.context = null;
      }

      if (null != sr.drawable) {
        // may cause JVM SIGSEGV:
        sr.drawable.setRealized(false);
        sr.drawable = null;
      }

      if (null != sr.screen) {
        sr.screen = null;
      }

      if (null != sr.device) {
        // may cause JVM SIGSEGV:
        sr.device.close();
        sr.device = null;
      }
    }
示例#5
1
  /** Adds an entity to the chunk. Args: entity */
  public void addEntity(Entity par1Entity) {
    this.hasEntities = true;
    int var2 = MathHelper.floor_double(par1Entity.posX / 16.0D);
    int var3 = MathHelper.floor_double(par1Entity.posZ / 16.0D);

    if (var2 != this.xPosition || var3 != this.zPosition) {
      this.worldObj.func_98180_V().func_98232_c("Wrong location! " + par1Entity);
      Thread.dumpStack();
    }

    int var4 = MathHelper.floor_double(par1Entity.posY / 16.0D);

    if (var4 < 0) {
      var4 = 0;
    }

    if (var4 >= this.entityLists.length) {
      var4 = this.entityLists.length - 1;
    }

    par1Entity.addedToChunk = true;
    par1Entity.chunkCoordX = this.xPosition;
    par1Entity.chunkCoordY = var4;
    par1Entity.chunkCoordZ = this.zPosition;
    this.entityLists[var4].add(par1Entity);
  }
示例#6
1
 /**
  * Validates and returns the location of a shader attribute.<br>
  * Uses either the cached value {@link #getCachedAttribLocation(String)} if valid, or the GLSL
  * queried via {@link GL2ES2#glGetAttribLocation(int, String)}.<br>
  * The location will be cached and set in the {@link GLArrayData} object.
  *
  * @return -1 if there is no such attribute available, otherwise >= 0
  * @throws GLException if no program is attached
  * @throws GLException if the program is not linked and no location was cached.
  * @see #getCachedAttribLocation(String)
  * @see #bindAttribLocation(GL2ES2, int, GLArrayData)
  * @see #bindAttribLocation(GL2ES2, int, String)
  * @see GL2ES2#glGetAttribLocation(int, String)
  * @see #getAttribute(String)
  */
 public int getAttribLocation(GL2ES2 gl, GLArrayData data) {
   if (null == shaderProgram) throw new GLException("No program is attached");
   final String name = data.getName();
   int location = getCachedAttribLocation(name);
   if (0 <= location) {
     data.setLocation(location);
   } else {
     if (!shaderProgram.linked()) throw new GLException("Program is not linked");
     location = data.setLocation(gl, shaderProgram.program());
     if (0 <= location) {
       Integer idx = new Integer(location);
       activeAttribLocationMap.put(name, idx);
       if (DEBUG) {
         System.err.println("ShaderState: glGetAttribLocation: " + name + ", loc: " + location);
       }
     } else if (verbose) {
       System.err.println(
           "ShaderState: glGetAttribLocation failed, no location for: "
               + name
               + ", loc: "
               + location);
       if (DEBUG) {
         Thread.dumpStack();
       }
     }
   }
   activeAttribDataMap.put(data.getName(), data);
   return location;
 }
示例#7
1
  /**
   * This method differentiates RollingFileAppender from its super class.
   *
   * @since 0.9.0
   */
  @Override
  protected void subAppend(LoggingEvent event) {
    if (id == null) {
      id = "" + new Random().nextInt();
      this.qw.write("#Session:" + id + ";" + Calendar.getInstance().getTime());
      this.qw.write(Layout.LINE_SEP);
    }
    this.qw.write(id);
    this.qw.write("#");
    this.qw.write(this.layout.format(event));
    if (layout.ignoresThrowable()) {
      String[] s = event.getThrowableStrRep();
      if (s != null) {
        Thread.dumpStack();
        int len = s.length;
        for (int i = 0; i < len; i++) {
          this.qw.write(id + "#[" + event.getThreadName() + "] " + event.getLevel() + " - \t");
          this.qw.write(s[i]);
          this.qw.write(Layout.LINE_SEP);
        }
      }
    }

    if (this.immediateFlush) {
      this.qw.flush();
    }
    if (fileName != null && ((CountingQuietWriter) qw).getCount() >= maxFileSize) {
      this.rollOver();
    }
  }
示例#8
1
 // Check if can add n bytes
 private final void check(int n) {
   if (this.bytes.length <= length + n - 1) {
     byte[] newBytes = new byte[this.bytes.length + n + initialCapacity];
     System.arraycopy(this.bytes, 0, newBytes, 0, this.bytes.length);
     this.bytes = newBytes;
     Thread.dumpStack();
   }
 }
示例#9
1
 /**
  * Show a message in a warning dialog window.
  *
  * @param errorTitle title for warning dialog.
  * @param errorMSG warning message.
  */
 public static void reportWarning(String errorTitle, String errorMSG) {
   ErrorDialog.showMessageDialog(
       PatchEdit.getInstance() /*[email protected]*/,
       errorMSG,
       errorTitle,
       JOptionPane.WARNING_MESSAGE);
   if ((debugLevel & DEBUG_MSG) != 0) System.out.println("WRN> '" + errorMSG + "' reported.");
   if ((debugLevel & DUMP_STACK) != 0) Thread.dumpStack();
 }
示例#10
1
文件: _.java 项目: GoWarp/pysonar2
    public static void die(String msg, Exception e) {
        System.err.println(msg);

        if (e != null) {
            System.err.println("Exception: " + e + "\n");
        }

        Thread.dumpStack();
        System.exit(2);
    }
 @Override
 public boolean lexiconHasFragment(ItemStack book, String key) {
   ChromaResearch r = ChromaResearch.getByName(key.toUpperCase());
   if (r == null) {
     ChromatiCraft.logger.logError(
         "A mod tried to fetch the state of an invalid research '" + key + "'!");
     Thread.dumpStack();
     return false;
   }
   return ItemChromaBook.hasPage(book, r);
 }
示例#12
1
文件: X11Util.java 项目: petr-s/jogl
  /**
   * Cleanup resources.
   *
   * <p>Called by {@link NativeWindowFactory#shutdown()}
   *
   * @see ToolkitProperties
   */
  public static void shutdown() {
    if (isInit) {
      synchronized (X11Util.class) {
        if (isInit) {
          final boolean isJVMShuttingDown = NativeWindowFactory.isJVMShuttingDown();
          if (DEBUG
              || ((openDisplayMap.size() > 0
                      || reusableDisplayList.size() > 0
                      || pendingDisplayList.size() > 0)
                  && (reusableDisplayList.size() != pendingDisplayList.size()
                      || !markAllDisplaysUnclosable))) {
            System.err.println(
                "X11Util.Display: Shutdown (JVM shutdown: "
                    + isJVMShuttingDown
                    + ", open (no close attempt): "
                    + openDisplayMap.size()
                    + "/"
                    + openDisplayList.size()
                    + ", reusable (open, marked uncloseable): "
                    + reusableDisplayList.size()
                    + ", pending (open in creation order): "
                    + pendingDisplayList.size()
                    + ")");
            if (DEBUG) {
              Thread.dumpStack();
            }
            if (openDisplayList.size() > 0) {
              X11Util.dumpOpenDisplayConnections();
            }
            if (DEBUG) {
              if (reusableDisplayList.size() > 0 || pendingDisplayList.size() > 0) {
                X11Util.dumpPendingDisplayConnections();
              }
            }
          }

          // Only at JVM shutdown time, since AWT impl. seems to
          // dislike closing of X11 Display's (w/ ATI driver).
          if (isJVMShuttingDown) {
            synchronized (globalLock) {
              isInit = false;
              closePendingDisplayConnections();
              openDisplayList.clear();
              reusableDisplayList.clear();
              pendingDisplayList.clear();
              openDisplayMap.clear();
              displayXineramaEnabledMap.clear();
              shutdown0();
            }
          }
        }
      }
    }
  }
 @Override
 public boolean playerHasResearch(EntityPlayer ep, String key) {
   ChromaResearch r = ChromaResearch.getByName(key.toUpperCase());
   if (r == null) {
     ChromatiCraft.logger.logError(
         "A mod tried to fetch the state of an invalid research '" + key + "'!");
     Thread.dumpStack();
     return false;
   }
   return this.playerHasFragment(ep, r);
 }
示例#14
1
 final void disableTrueDoubleBuffering() {
   if (useTrueDoubleBuffering) {
     if (!IGNORE_DISABLE_TRUE_DOUBLE_BUFFERING) {
       if (LOG_DISABLE_TRUE_DOUBLE_BUFFERING) {
         System.out.println("Disabling true double buffering for " + this);
         Thread.dumpStack();
       }
       useTrueDoubleBuffering = false;
       RepaintManager.currentManager(this).doubleBufferingChanged(this);
     }
   }
 }
示例#15
1
  /** Allocates the block for a query. */
  public final boolean allocate() {
    int useCount;

    do {
      useCount = _useCount.get();

      if (useCount < 1) {
        // The block might be LRU'd just as we're about to allocated it.
        // in that case, we need to allocate a new block, not reuse
        // the old one.
        return false;
      }
    } while (!_useCount.compareAndSet(useCount, useCount + 1));

    if (_isLogFine) {
      if (getBuffer() == null) {
        _useCount.decrementAndGet();
        Thread.dumpStack();
        log.fine(this + " null buffer " + this + " " + _useCount.get());
        return false;
      }

      if (log.isLoggable(Level.ALL)) log.log(Level.ALL, this + " allocate (" + useCount + ")");

      // System.out.println(this + " ALLOCATE " + _useCount);

      if (useCount > 32 && log.isLoggable(Level.FINE)) {
        log.fine("using " + this + " " + useCount + " times");

        if (log.isLoggable(Level.FINER)) {
          Thread.dumpStack();
        }
      }
    }

    return true;
  }
 @Override
 public HashSet<String> getPrerequisites(String key) {
   ChromaResearch r = ChromaResearch.getByName(key.toUpperCase());
   if (r == null) {
     ChromatiCraft.logger.logError(
         "A mod tried to fetch the state of an invalid research '" + key + "'!");
     Thread.dumpStack();
     return null;
   }
   Collection<ChromaResearch> c = this.getPreReqsFor(r);
   HashSet<String> h = new HashSet();
   for (ChromaResearch req : c) {
     h.add(req.name());
   }
   return h;
 }
示例#17
1
  /** like wakeAfter() except always in real (wallclock) time. */
  public Alarm wakeAfterRealTime(long delayTime) {
    if (delayTime < WAKE_LATENCY) {
      System.err.println(
          "Warning: wakeAfterRealTime("
              + delayTime
              + "ms) is less than "
              + WAKE_LATENCY
              + "ms in the future!");
      Thread.dumpStack();
      delayTime = WAKE_LATENCY;
    }

    long absTime = System.currentTimeMillis() + delayTime;
    PluginAlarm pa = new PluginAlarm(absTime);
    getAlarmService().addRealTimeAlarm(pa);
    return pa;
  }
示例#18
0
  /** like wakeAt() except always in real (wallclock) time. */
  public Alarm wakeAtRealTime(long wakeTime) {
    long cur = System.currentTimeMillis() + WAKE_LATENCY;
    if (wakeTime < cur) {
      System.err.println(
          "Warning: wakeAtRealTime("
              + (new Date(wakeTime))
              + ") is less than "
              + WAKE_LATENCY
              + "ms in the future!");
      Thread.dumpStack();
      wakeTime = cur;
    }

    PluginAlarm pa = new PluginAlarm(wakeTime);
    getAlarmService().addRealTimeAlarm(pa);
    return pa;
  }
示例#19
0
 /** Removes the top key processor from the stack */
 public void popKeyProcessorStack() {
   if (null != m_CurrentActiveKeyProcessor) {
     KeyboardFocusManager.getCurrentKeyboardFocusManager()
         .removeKeyEventPostProcessor(this.m_CurrentActiveKeyProcessor);
     m_CurrentActiveKeyProcessor = null;
   }
   if (!m_KeyProcessorStack.isEmpty()) {
     m_CurrentActiveKeyProcessor = (KeyEventPostProcessor) m_KeyProcessorStack.removeLast();
     if (null != m_CurrentActiveKeyProcessor) {
       KeyboardFocusManager.getCurrentKeyboardFocusManager()
           .addKeyEventPostProcessor(m_CurrentActiveKeyProcessor);
     }
   } else {
     Thread.dumpStack();
     System.out.println(
         "ERROR: " + getClass().getName() + ".popKeyProcessorStack() - Over pop detected");
   }
 }
示例#20
0
 /**
  * Gets the location of a shader uniform.<br>
  * Uses either the cached value {@link #getCachedUniformLocation(String)} if valid, or the GLSL
  * queried via {@link GL2ES2#glGetUniformLocation(int, String)}.<br>
  * The location will be cached.
  *
  * <p>The current shader program ({@link #attachShaderProgram(GL2ES2, ShaderProgram)}) must be in
  * use ({@link #useProgram(GL2ES2, boolean) }) !
  *
  * @return -1 if there is no such attribute available, otherwise >= 0
  * @throws GLException is the program is not linked
  * @see #glGetUniformLocation
  * @see javax.media.opengl.GL2ES2#glGetUniformLocation
  * @see #getUniformLocation
  * @see ShaderProgram#glReplaceShader
  */
 public final int getUniformLocation(GL2ES2 gl, String name) {
   if (!shaderProgram.inUse()) throw new GLException("Program is not in use");
   int location = getCachedUniformLocation(name);
   if (0 > location) {
     if (!shaderProgram.linked()) throw new GLException("Program is not linked");
     location = gl.glGetUniformLocation(shaderProgram.program(), name);
     if (0 <= location) {
       Integer idx = new Integer(location);
       activeUniformLocationMap.put(name, idx);
     } else if (verbose) {
       System.err.println(
           "ShaderState: glUniform failed, no location for: " + name + ", index: " + location);
       if (DEBUG) {
         Thread.dumpStack();
       }
     }
   }
   return location;
 }
示例#21
0
  /**
   * register keystrokes here which are for the WHEN_IN_FOCUSED_WINDOW case. Other types of
   * keystrokes will be handled by walking the hierarchy That simplifies some potentially hairy
   * stuff.
   */
  public void registerKeyStroke(KeyStroke k, JComponent c) {
    Container topContainer = getTopAncestor(c);
    if (topContainer == null) {
      return;
    }
    Hashtable keyMap = containerMap.get(topContainer);

    if (keyMap == null) { // lazy evaluate one
      keyMap = registerNewTopContainer(topContainer);
    }

    Object tmp = keyMap.get(k);
    if (tmp == null) {
      keyMap.put(k, c);
    } else if (tmp instanceof Vector) { // if there's a Vector there then add to it.
      Vector v = (Vector) tmp;
      if (!v.contains(c)) { // only add if this keystroke isn't registered for this component
        v.addElement(c);
      }
    } else if (tmp instanceof JComponent) {
      // if a JComponent is there then remove it and replace it with a vector
      // Then add the old compoennt and the new compoent to the vector
      // then insert the vector in the table
      if (tmp != c) { // this means this is already registered for this component, no need to dup
        Vector<JComponent> v = new Vector<JComponent>();
        v.addElement((JComponent) tmp);
        v.addElement(c);
        keyMap.put(k, v);
      }
    } else {
      System.out.println("Unexpected condition in registerKeyStroke");
      Thread.dumpStack();
    }

    componentKeyStrokeMap.put(new ComponentKeyStrokePair(c, k), topContainer);

    // Check for EmbeddedFrame case, they know how to process accelerators even
    // when focus is not in Java
    if (topContainer instanceof EmbeddedFrame) {
      ((EmbeddedFrame) topContainer).registerAccelerator(k);
    }
  }
示例#22
0
 private boolean disableVertexAttribArray(GL2ES2 gl, String name, int location) {
   activedAttribEnabledMap.put(name, Boolean.FALSE);
   if (0 > location) {
     location = getAttribLocation(gl, name);
     if (0 > location) {
       if (verbose) {
         System.err.println(
             "ShaderState: glDisableVertexAttribArray failed, no index for: " + name);
         if (DEBUG) {
           Thread.dumpStack();
         }
       }
       return false;
     }
   }
   if (DEBUG) {
     System.err.println("ShaderState: glDisableVertexAttribArray: " + name);
   }
   gl.glDisableVertexAttribArray(location);
   return true;
 }
示例#23
0
  // Special exec edition for RhoBluetoothManager
  // TODO: Use future pattern to return result and wait
  @Deprecated
  public static void sync_exec(final Runnable r) {
    try {
      RhodesActivity ra = RhodesActivity.safeGetInstance();

      long thrId = Thread.currentThread().getId();
      if (ra.getUiThreadId() == thrId) {
        // We are already in UI thread
        r.run();
      } else {
        // Post request to UI thread and wait when it would be done
        synchronized (r) {
          ra.post(new PerformOnUiThread(r));
          r.wait();
        }
      }
    } catch (Exception e) {
      Logger.E(TAG, "exec failed: " + e.getMessage());
      Thread.dumpStack();
    }
  }
  private void printMenuElementArray(MenuElement path[], boolean dumpStack) {
    System.out.println("Path is(");
    int i, j;
    for (i = 0, j = path.length; i < j; i++) {
      for (int k = 0; k <= i; k++) System.out.print("  ");
      MenuElement me = path[i];
      if (me instanceof JMenuItem) {
        System.out.println(((JMenuItem) me).getText() + ", ");
      } else if (me instanceof JMenuBar) {
        System.out.println("JMenuBar, ");
      } else if (me instanceof JPopupMenu) {
        System.out.println("JPopupMenu, ");
      } else if (me == null) {
        System.out.println("NULL , ");
      } else {
        System.out.println("" + me + ", ");
      }
    }
    System.out.println(")");

    if (dumpStack == true) Thread.dumpStack();
  }
示例#25
0
 public void func_1000_a(Entity entity) {
   field_1523_r = true;
   int i = MathHelper.func_1108_b(entity.field_611_ak / 16D);
   int j = MathHelper.func_1108_b(entity.field_609_am / 16D);
   if (i != field_1531_j || j != field_1530_k) {
     System.out.println(
         (new StringBuilder()).append("Wrong location! ").append(entity).toString());
     Thread.dumpStack();
   }
   int k = MathHelper.func_1108_b(entity.field_610_al / 16D);
   if (k < 0) {
     k = 0;
   }
   if (k >= field_1528_m.length) {
     k = field_1528_m.length - 1;
   }
   entity.field_621_aZ = true;
   entity.field_657_ba = field_1531_j;
   entity.field_656_bb = k;
   entity.field_654_bc = field_1530_k;
   field_1528_m[k].add(entity);
 }
示例#26
0
 /**
  * This method is like the measureSleep() method above, only for the wait() method instead of
  * sleep().
  */
 private synchronized void measureWait() {
   System.out.printf("                                measured\n");
   System.out.printf("wait time   iterations   total time   per-wait\n");
   for (int sleepTime = 1; sleepTime <= 20; ++sleepTime) {
     int iterations = (sleepTime == 0) ? 10000 : (1000 / sleepTime);
     long startTime = System.nanoTime();
     for (int i = 0; i < iterations; ++i) {
       try {
         wait(sleepTime);
       } catch (Exception e) {
         System.out.println("Exception: " + e);
         Thread.dumpStack();
       }
     }
     long endTime = System.nanoTime();
     long totalTime = (endTime - startTime) / 1000000;
     float calculatedSleepTime = totalTime / (float) iterations;
     System.out.printf(
         "  %2d          %5d         %4d       %5.2f\n",
         sleepTime, iterations, totalTime, calculatedSleepTime);
   }
 }
示例#27
0
 public void addEntity(Entity entity) {
   hasEntities = true;
   int i = MathHelper.floor_double(entity.posX / 16D);
   int j = MathHelper.floor_double(entity.posZ / 16D);
   if (i != xPosition || j != zPosition) {
     System.out.println(
         (new StringBuilder()).append("Wrong location! ").append(entity).toString());
     Thread.dumpStack();
   }
   int k = MathHelper.floor_double(entity.posY / 16D);
   if (k < 0) {
     k = 0;
   }
   if (k >= entities.length) {
     k = entities.length - 1;
   }
   entity.addedToChunk = true;
   entity.chunkCoordX = xPosition;
   entity.chunkCoordY = k;
   entity.chunkCoordZ = zPosition;
   entities[k].add(entity);
 }
示例#28
0
  public static void joinHerd(
      final String dc, final String herd, final Endpoint endpoint, Endpoint shepardAddress) {
    Thread.dumpStack();

    final Endpoint shepard = Networking.resolve(shepardAddress.getHost(), PORT);
    final RpcEndpoint sock = Networking.rpcConnect(TransportProvider.DEFAULT).toDefaultService();

    Log.info(IP.localHostname() + " Contacting shepard at: " + shepard + " to join: " + herd);
    System.err.println(
        IP.localHostname() + " Contacting shepard at: " + shepard + " to join: " + herd);

    new PeriodicTask(2.0, 1.0) {
      public void run() {
        try {
          sock.send(
              shepard,
              new JoinHerdRequest(dc, herd, endpoint),
              new HerdProtoHandler() {
                public void onReceive(JoinHerdReply r) {
                  herds = r.herds();
                  lastChange = System.currentTimeMillis() - r.age();
                  Log.info(
                      String.format(
                          "Received Herd information: lastChange : [%.1f s] ago, data: %s\n",
                          age() / 1000.0, herds));

                  Threading.synchronizedNotifyAllOn(herds);
                }
              },
              0);
          if (stopProbing) cancel();

        } catch (Exception x) {
          Log.warning("Cannot connect to shepard at: " + shepard + " to join: " + herd);
        }
      }
    };
  }
示例#29
0
  @Override
  protected final SharedResource getOrCreateSharedResourceImpl(AbstractGraphicsDevice adevice) {
    if (null
        == sharedMap) { // null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper
      return null;
    }

    if (needsToCreateSharedResource(defaultDevice.getUniqueID(), null)) {
      if (DEBUG) {
        System.err.println(
            "EGLDrawableFactory.createShared: (defaultDevice): req. device: "
                + adevice
                + ", defaultDevice "
                + defaultDevice);
        Thread.dumpStack();
      }
      if (null != defaultSharedResource) {
        dumpMap();
        throw new InternalError("defaultSharedResource already exist: " + defaultSharedResource);
      }
      defaultSharedResource = createEGLSharedResourceImpl(defaultDevice);
    }

    final String key = adevice.getUniqueID();
    if (defaultDevice.getUniqueID().equals(key)) {
      return defaultSharedResource;
    } else {
      if (null == defaultSharedResource) { // defaultDevice must be initialized before host-device
        dumpMap();
        throw new InternalError("defaultSharedResource does not exist");
      }
      final SharedResource[] existing = new SharedResource[] {null};
      if (!needsToCreateSharedResource(key, existing)) {
        return existing[0];
      }
      return createEGLSharedResourceImpl(adevice);
    }
  }
示例#30
0
 /**
  * Validates and returns the location of a shader uniform.<br>
  * Uses either the cached value {@link #getCachedUniformLocation(String)} if valid, or the GLSL
  * queried via {@link GL2ES2#glGetUniformLocation(int, String)}.<br>
  * The location will be cached and set in the {@link GLUniformData} object.
  *
  * <p>The current shader program ({@link #attachShaderProgram(GL2ES2, ShaderProgram)}) must be in
  * use ({@link #useProgram(GL2ES2, boolean) }) !
  *
  * @return -1 if there is no such attribute available, otherwise >= 0
  * @throws GLException is the program is not linked
  * @see #glGetUniformLocation
  * @see javax.media.opengl.GL2ES2#glGetUniformLocation
  * @see #getUniformLocation
  * @see ShaderProgram#glReplaceShader
  */
 public int getUniformLocation(GL2ES2 gl, GLUniformData data) {
   if (!shaderProgram.inUse()) throw new GLException("Program is not in use");
   final String name = data.getName();
   int location = getCachedUniformLocation(name);
   if (0 <= location) {
     data.setLocation(location);
   } else {
     if (!shaderProgram.linked()) throw new GLException("Program is not linked");
     location = data.setLocation(gl, shaderProgram.program());
     if (0 <= location) {
       Integer idx = new Integer(location);
       activeUniformLocationMap.put(name, idx);
     } else if (verbose) {
       System.err.println(
           "ShaderState: glUniform failed, no location for: " + name + ", index: " + location);
       if (DEBUG) {
         Thread.dumpStack();
       }
     }
   }
   activeUniformDataMap.put(name, data);
   return location;
 }