@Override public <V> Future<V> enqueue(Callable<V> callable) { AppTask<V> task = new AppTask<V>(callable); taskQueue.add(task); return task; }
/** * Runs tasks enqueued via {@link #enqueue(Callable)} */ protected void runQueuedTasks() { AppTask<?> task; while( (task = taskQueue.poll()) != null ) { if (!task.isCancelled()) { task.invoke(); } } }
public V get() throws InterruptedException, ExecutionException { stateLock.lock(); try { while (!isDone()) { finishedCondition.await(); } if (exception != null) { throw exception; } return result; } finally { stateLock.unlock(); } }
/** * Runs tasks enqueued via {@link #enqueue(Callable)} */ protected void runQueuedTasks() { AppTask<?> task; while( (task = taskQueue.poll()) != null ) { if (!task.isCancelled()) { task.invoke(); } } }
/** * Enqueues a task/callable object to execute in the jME3 * rendering thread. */ public <V> Future<V> enqueue(Callable<V> callable) { AppTask<V> task = new AppTask<V>(callable); taskQueue.add(task); return task; }
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { stateLock.lock(); try { if (!isDone()) { finishedCondition.await(timeout, unit); } if (exception != null) { throw exception; } if (result == null) { throw new TimeoutException("Object not returned in time allocated."); } return result; } finally { stateLock.unlock(); } }
@Override protected void controlUpdate(float tpf) { AppTask<?> task = taskQueue.poll(); toploop: do { if (task == null) break; while (task.isCancelled()) { task = taskQueue.poll(); if (task == null) break toploop; } task.invoke(); } while (((task = taskQueue.poll()) != null)); }
/** * calls the callable on the next physics tick (ensuring e.g. force applying) * @param <V> * @param callable * @return */ public <V> Future<V> enqueue(Callable<V> callable) { AppTask<V> task = new AppTask<V>(callable); pQueue.add(task); return task; }
public V get() throws InterruptedException, ExecutionException { stateLock.lock(); try { while (!isDone()) { finishedCondition.await(); } if (exception != null) { throw exception; } return result; } finally { stateLock.unlock(); } }
/** * Callback invoked just before the physics is stepped. * <p> * This method is invoked from native code. * * @param timeStep the time per physics step (in seconds, ≥0) */ private void preTick_native(float f) { AppTask task; while((task=pQueue.poll())!=null){ if(task.isCancelled())continue; try{ task.invoke(); } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); } } for (Iterator<PhysicsTickListener> it = tickListeners.iterator(); it.hasNext();) { PhysicsTickListener physicsTickCallback = it.next(); physicsTickCallback.prePhysicsTick(this, f); } }
/** * Invoke the specified callable during the next physics tick. This is * useful for applying forces. * * @param <V> the return type of the callable * @param callable which callable to invoke * @return Future object */ public <V> Future<V> enqueue(Callable<V> callable) { AppTask<V> task = new AppTask<V>(callable); pQueue.add(task); return task; }
public V get() throws InterruptedException, ExecutionException { stateLock.lock(); try { while (!isDone()) { finishedCondition.await(); } if (exception != null) { throw exception; } return result; } finally { stateLock.unlock(); } }
@Override public void internalTick(DynamicsWorld dw, float f) { //execute task list AppTask task = pQueue.poll(); task = pQueue.poll(); while (task != null) { while (task.isCancelled()) { task = pQueue.poll(); } try { task.invoke(); } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); } task = pQueue.poll(); } for (Iterator<PhysicsTickListener> it = tickListeners.iterator(); it.hasNext();) { PhysicsTickListener physicsTickCallback = it.next(); physicsTickCallback.prePhysicsTick(space, f); } } };
/** * Enqueues a task/callable object to execute in the jME3 * rendering thread. * <p> * Callables are executed right at the beginning of the main loop. * They are executed even if the application is currently paused * or out of focus. * * @param callable The callable to run in the main jME3 thread */ public <V> Future<V> enqueue(Callable<V> callable) { AppTask<V> task = new AppTask<V>(callable); taskQueue.add(task); return task; }
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { stateLock.lock(); try { if (!isDone()) { finishedCondition.await(timeout, unit); } if (exception != null) { throw exception; } if (result == null) { throw new TimeoutException("Object not returned in time allocated."); } return result; } finally { stateLock.unlock(); } }
/** * Runs tasks enqueued via {@link #enqueue(Callable)} */ protected void runQueuedTasks() { AppTask<?> task; while( (task = taskQueue.poll()) != null ) { if (!task.isCancelled()) { task.invoke(); } } }
public static <V> Future<V> enqueueOnThisThread(Callable<V> callable) { AppTask<V> task = new AppTask<V>(callable); System.out.println("created apptask"); pQueueTL.get().add(task); return task; }
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { stateLock.lock(); try { if (!isDone()) { finishedCondition.await(timeout, unit); } if (exception != null) { throw exception; } if (result == null) { throw new TimeoutException("Object not returned in time allocated."); } return result; } finally { stateLock.unlock(); } }
@Override protected void controlUpdate(float tpf) { AppTask<?> task = taskQueue.poll(); toploop: do { if (task == null) break; while (task.isCancelled()) { task = taskQueue.poll(); if (task == null) break toploop; } task.invoke(); } while (((task = taskQueue.poll()) != null)); }
/** * Enqueue a callable on the currently executing thread. * * @param <V> the task's result type * @param callable the task to be executed * @return a new task (not null) */ public static <V> Future<V> enqueueOnThisThread(Callable<V> callable) { AppTask<V> task = new AppTask<V>(callable); System.out.println("created apptask"); pQueueTL.get().add(task); return task; }