protected ThreadPool newThreadPool() { return new ThreadPool(server.getMaxThreads(), "XML-RPC"); }
/** Starts a task immediately. * @param pTask The task being started. * @return True, if the task could be started immediately. False, if * the maxmimum number of concurrent tasks was exceeded. If so, you * might consider to use the {@link #addTask(ThreadPool.Task)} method instead. */ public boolean startTask(Task pTask) { final Poolable poolable = getPoolable(pTask, false); if (poolable == null) { return false; } poolable.start(pTask); return true; }
/** * Stop listening on the server port. Shutting down our {@link * #listener} effectively breaks it out of its {@link #run()} * loop. * * @see #run() */ public synchronized void shutdown() { // Stop accepting client connections if (listener != null) { Thread l = listener; listener = null; l.interrupt(); if (pool != null) { pool.shutdown(); } } }
if (pool.startTask(task)) { socket = null; } else { log("Maximum load of " + pool.getMaxThreads() + " exceeded, rejecting client"); pool.shutdown();
void repool(Poolable pPoolable) { boolean discarding = false; Task task = null; Poolable poolable = null; synchronized (this) { if (runningThreads.remove(pPoolable)) { if (maxSize != 0 && runningThreads.size() + waitingThreads.size() >= maxSize) { discarding = true; } else { waitingThreads.add(pPoolable); if (waitingTasks.size() > 0) { task = (Task) waitingTasks.remove(waitingTasks.size() - 1); poolable = getPoolable(task, false); } } } else { discarding = true; } if (discarding) { remove(pPoolable); } } if (poolable != null) { poolable.start(task); } if (discarding) { pPoolable.shutdown(); } }
public void run() { while (!shuttingDown) { final Task t = getTask(); if (t == null) { try { synchronized (this) { if (!shuttingDown && getTask() == null) { wait(); } } } catch (InterruptedException e) { // Do nothing } } else { try { t.run(); resetTask(); repool(Poolable.this); } catch (Throwable e) { remove(Poolable.this); Poolable.this.shutdown(); resetTask(); } } } } };
if (pool.startTask(task)) { socket = null; } else { log("Maximum load of " + pool.getMaxThreads() + " exceeded, rejecting client"); pool.shutdown();
void repool(Poolable pPoolable) { boolean discarding = false; Task task = null; Poolable poolable = null; synchronized (this) { if (runningThreads.remove(pPoolable)) { if (maxSize != 0 && runningThreads.size() + waitingThreads.size() >= maxSize) { discarding = true; } else { waitingThreads.add(pPoolable); if (waitingTasks.size() > 0) { task = (Task) waitingTasks.remove(waitingTasks.size() - 1); poolable = getPoolable(task, false); } } } else { discarding = true; } if (discarding) { remove(pPoolable); } } if (poolable != null) { poolable.start(task); } if (discarding) { pPoolable.shutdown(); } }
public void run() { while (!shuttingDown) { final Task t = getTask(); if (t == null) { try { synchronized (this) { if (!shuttingDown && getTask() == null) { wait(); } } } catch (InterruptedException e) { // Do nothing } } else { try { t.run(); resetTask(); repool(Poolable.this); } catch (Throwable e) { remove(Poolable.this); Poolable.this.shutdown(); resetTask(); } } } } };
if (pool.startTask(task)) { socket = null; } else { log("Maximum load of " + pool.getMaxThreads() + " exceeded, rejecting client"); pool.shutdown();
void repool(Poolable pPoolable) { boolean discarding = false; Task task = null; Poolable poolable = null; synchronized (this) { if (runningThreads.remove(pPoolable)) { if (maxSize != 0 && runningThreads.size() + waitingThreads.size() >= maxSize) { discarding = true; } else { waitingThreads.add(pPoolable); if (waitingTasks.size() > 0) { task = (Task) waitingTasks.remove(waitingTasks.size() - 1); poolable = getPoolable(task, false); } } } else { discarding = true; } if (discarding) { remove(pPoolable); } } if (poolable != null) { poolable.start(task); } if (discarding) { pPoolable.shutdown(); } }
/** Adds a task for immediate or deferred execution. * @param pTask The task being added. * @return True, if the task was started immediately. False, if * the task will be executed later. * @deprecated No longer in use. */ public boolean addTask(Task pTask) { final Poolable poolable = getPoolable(pTask, true); if (poolable != null) { poolable.start(pTask); return true; } return false; }
protected ThreadPool newThreadPool() { return new ThreadPool(server.getMaxThreads(), "XML-RPC"); }
/** * Stop listening on the server port. Shutting down our {@link * #listener} effectively breaks it out of its {@link #run()} * loop. * * @see #run() */ public synchronized void shutdown() { // Stop accepting client connections if (listener != null) { Thread l = listener; listener = null; l.interrupt(); if (pool != null) { pool.shutdown(); } } }
public void run() { while (!shuttingDown) { final Task t = getTask(); if (t == null) { try { synchronized (this) { if (!shuttingDown && getTask() == null) { wait(); } } } catch (InterruptedException e) { // Do nothing } } else { try { t.run(); resetTask(); repool(Poolable.this); } catch (Throwable e) { remove(Poolable.this); Poolable.this.shutdown(); resetTask(); } } } } };
/** Starts a task immediately. * @param pTask The task being started. * @return True, if the task could be started immediately. False, if * the maxmimum number of concurrent tasks was exceeded. If so, you * might consider to use the {@link #addTask(ThreadPool.Task)} method instead. */ public boolean startTask(Task pTask) { final Poolable poolable = getPoolable(pTask, false); if (poolable == null) { return false; } poolable.start(pTask); return true; }
protected ThreadPool newThreadPool() { return new ThreadPool(server.getMaxThreads(), "XML-RPC"); }
/** * Stop listening on the server port. Shutting down our {@link * #listener} effectively breaks it out of its {@link #run()} * loop. * * @see #run() */ public synchronized void shutdown() { // Stop accepting client connections if (listener != null) { Thread l = listener; listener = null; l.interrupt(); if (pool != null) { pool.shutdown(); } } }
/** Starts a task immediately. * @param pTask The task being started. * @return True, if the task could be started immediately. False, if * the maxmimum number of concurrent tasks was exceeded. If so, you * might consider to use the {@link #addTask(ThreadPool.Task)} method instead. */ public boolean startTask(Task pTask) { final Poolable poolable = getPoolable(pTask, false); if (poolable == null) { return false; } poolable.start(pTask); return true; }
/** Adds a task for immediate or deferred execution. * @param pTask The task being added. * @return True, if the task was started immediately. False, if * the task will be executed later. * @deprecated No longer in use. */ public boolean addTask(Task pTask) { final Poolable poolable = getPoolable(pTask, true); if (poolable != null) { poolable.start(pTask); return true; } return false; }