/** * Method is called by a thread pool each time a dequeued task has been canceled * instead of being processed. * * @param task */ protected void onTaskCancelled(Runnable task) { ProbeNotifier.notifyTaskCancelled(this, task); }
/** * <p> * This method will be invoked when a the specified {@link Runnable} has * completed execution. * </p> * * @param task the unit of work that has completed processing */ protected void onTaskCompletedEvent(Runnable task) { ProbeNotifier.notifyTaskCompleted(this, task); }
/** * Method is called by a thread pool each time a task has been dequeued from * a task queue. * * @param task */ protected void onTaskDequeued(Runnable task) { ProbeNotifier.notifyTaskDequeued(this, task); }
/** * Method is called by a thread pool, when new task could not be added * to a task queue, because task queue is full. * throws {@link RejectedExecutionException} */ protected void onTaskQueueOverflow() { ProbeNotifier.notifyTaskQueueOverflow(this); throw new RejectedExecutionException( "The thread pool's task queue is full, limit: " + config.getQueueLimit()); }
/** * Method is called by <tt>AbstractThreadPool</tt>, when maximum number of * worker threads is reached and task will need to wait in task queue, until * one of the threads will be able to process it. */ protected void onMaxNumberOfThreadsReached() { ProbeNotifier.notifyMaxNumberOfThreads(this, config.getMaxPoolSize()); }
/** * Method is called by a thread pool each time new task has been queued to * a task queue. * * @param task */ protected void onTaskQueued(Runnable task) { ProbeNotifier.notifyTaskQueued(this, task); }
/** * Method is called by {@link Worker}, when it's starting * {@link Worker#run()} method execution, which means, that ThreadPool's * thread is getting active and ready to process tasks. * This method is called from {@link Worker}'s thread. * * @param worker */ protected void onWorkerStarted(final Worker worker) { if (delayedQueue != null) { delayedQueue.add(worker, NEVER_TIMEOUT, TimeUnit.MILLISECONDS); } ProbeNotifier.notifyThreadAllocated(this, worker.t); }
/** * {@inheritDoc} */ @Override public void shutdown() { synchronized (stateLock) { if (running) { running = false; poisonAll(); stateLock.notifyAll(); ProbeNotifier.notifyThreadPoolStopped(this); } } }
public FixedThreadPool(ThreadPoolConfig config) { super(config); this.workQueue = config.getQueue() != null ? (BlockingQueue<Runnable>) config.getQueue() : (BlockingQueue<Runnable>) config.setQueue( new LinkedTransferQueue<>()).getQueue(); int poolSize = config.getMaxPoolSize(); synchronized (stateLock) { while (poolSize-- > 0) { doStartWorker(); } } ProbeNotifier.notifyThreadPoolStarted(this); super.onMaxNumberOfThreadsReached(); }
/** * Method is called by {@link Worker}, when it's completing * {@link Worker#run()} method execution, which in most cases means, * that ThreadPool's thread will be released. This method is called from * {@link Worker}'s thread. * * @param worker */ protected void onWorkerExit(Worker worker) { synchronized (stateLock) { workers.remove(worker); if (delayedQueue != null) { delayedQueue.remove(worker); } if (workers.isEmpty()) { // notify awaitTermination threads stateLock.notifyAll(); } } ProbeNotifier.notifyThreadReleased(this, worker.t); }
/** * Method is called by a thread pool, when new task could not be added * to a task queue, because task queue is full. * throws {@link RejectedExecutionException} */ protected void onTaskQueueOverflow() { ProbeNotifier.notifyTaskQueueOverflow(this); throw new RejectedExecutionException( "The thread pool's task queue is full, limit: " + config.getQueueLimit()); }
/** * Method is called by <tt>AbstractThreadPool</tt>, when maximum number of * worker threads is reached and task will need to wait in task queue, until * one of the threads will be able to process it. */ protected void onMaxNumberOfThreadsReached() { ProbeNotifier.notifyMaxNumberOfThreads(this, config.getMaxPoolSize()); }
/** * Method is called by a thread pool each time new task has been queued to * a task queue. * * @param task */ protected void onTaskQueued(Runnable task) { ProbeNotifier.notifyTaskQueued(this, task); }
/** * Method is called by {@link Worker}, when it's starting * {@link Worker#run()} method execution, which means, that ThreadPool's * thread is getting active and ready to process tasks. * This method is called from {@link Worker}'s thread. * * @param worker */ protected void onWorkerStarted(final Worker worker) { if (delayedQueue != null) { delayedQueue.add(worker, NEVER_TIMEOUT, TimeUnit.MILLISECONDS); } ProbeNotifier.notifyThreadAllocated(this, worker.t); }
/** * {@inheritDoc} */ @Override public void shutdown() { synchronized (stateLock) { if (running) { running = false; poisonAll(); stateLock.notifyAll(); ProbeNotifier.notifyThreadPoolStopped(this); } } }
public FixedThreadPool(ThreadPoolConfig config) { super(config); this.workQueue = config.getQueue() != null ? (BlockingQueue<Runnable>) config.getQueue() : (BlockingQueue<Runnable>) config.setQueue( new LinkedTransferQueue<>()).getQueue(); int poolSize = config.getMaxPoolSize(); synchronized (stateLock) { while (poolSize-- > 0) { doStartWorker(); } } ProbeNotifier.notifyThreadPoolStarted(this); super.onMaxNumberOfThreadsReached(); }
/** * Method is called by {@link Worker}, when it's completing * {@link Worker#run()} method execution, which in most cases means, * that ThreadPool's thread will be released. This method is called from * {@link Worker}'s thread. * * @param worker */ protected void onWorkerExit(Worker worker) { synchronized (stateLock) { workers.remove(worker); if (delayedQueue != null) { delayedQueue.remove(worker); } if (workers.isEmpty()) { // notify awaitTermination threads stateLock.notifyAll(); } } ProbeNotifier.notifyThreadReleased(this, worker.t); }
/** * Method is called by a thread pool each time a dequeued task has been canceled * instead of being processed. * * @param task */ protected void onTaskCancelled(Runnable task) { ProbeNotifier.notifyTaskCancelled(this, task); }
/** * <p> * This method will be invoked when a the specified {@link Runnable} has * completed execution. * </p> * * @param task the unit of work that has completed processing */ protected void onTaskCompletedEvent(Runnable task) { ProbeNotifier.notifyTaskCompleted(this, task); }
/** * Method is called by a thread pool, when new task could not be added * to a task queue, because task queue is full. * throws {@link RejectedExecutionException} */ protected void onTaskQueueOverflow() { ProbeNotifier.notifyTaskQueueOverflow(this); throw new RejectedExecutionException( "The thread pool's task queue is full, limit: " + config.getQueueLimit()); }