You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2011/11/10 06:55:41 UTC
svn commit: r1200171 - in
/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads: Constants.java
LimitLatch.java ResizableExecutor.java TaskQueue.java TaskThread.java
TaskThreadFactory.java ThreadPoolExecutor.java
Author: kkolinko
Date: Thu Nov 10 05:55:40 2011
New Revision: 1200171
URL: http://svn.apache.org/viewvc?rev=1200171&view=rev
Log:
Merging revision 1187781 from tomcat/trunk:
Whitespace removal from /java/org/apache/tomcat
I won't merge all of it (as it spans bcel etc.), but only our code.
Part 7, the last one.
I am not updating mergeinfo, because not all of the original revision was merged.
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/Constants.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/LimitLatch.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ResizableExecutor.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThread.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/Constants.java?rev=1200171&r1=1200170&r2=1200171&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/Constants.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/Constants.java Thu Nov 10 05:55:40 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/LimitLatch.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/LimitLatch.java?rev=1200171&r1=1200170&r2=1200171&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/LimitLatch.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/LimitLatch.java Thu Nov 10 05:55:40 2011
@@ -56,7 +56,7 @@ public class LimitLatch {
private final AtomicLong count;
private volatile long limit;
private volatile boolean released = false;
-
+
/**
* Instantiates a LimitLatch object with an initial limit.
* @param limit - maximum number of concurrent acquisitions of this latch
@@ -83,7 +83,7 @@ public class LimitLatch {
* the new limit. If the limit is increased, threads currently in the queue
* may not be issued one of the newly available shares until the next
* request is made for a latch.
- *
+ *
* @param limit The new limit
*/
public void setLimit(long limit) {
@@ -107,7 +107,7 @@ public class LimitLatch {
sync.releaseShared(0);
return count.get();
}
-
+
/**
* Releases all waiting threads and causes the {@link #limit} to be ignored
* until {@link #reset()} is called.
@@ -116,7 +116,7 @@ public class LimitLatch {
released = true;
return sync.releaseShared(0);
}
-
+
/**
* Resets the latch and initializes the shared acquisition counter to zero.
* @see #releaseAll()
@@ -125,7 +125,7 @@ public class LimitLatch {
this.count.set(0);
released = false;
}
-
+
/**
* Returns <code>true</code> if there is at least one thread waiting to
* acquire the shared lock, otherwise returns <code>false</code>.
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ResizableExecutor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ResizableExecutor.java?rev=1200171&r1=1200170&r2=1200171&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ResizableExecutor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ResizableExecutor.java Thu Nov 10 05:55:40 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,7 +26,7 @@ public interface ResizableExecutor exten
* @return the number of threads
*/
public int getPoolSize();
-
+
public int getMaxThreads();
/**
@@ -36,9 +36,9 @@ public interface ResizableExecutor exten
* @return the number of threads
*/
public int getActiveCount();
-
+
public boolean resizePool(int corePoolSize, int maximumPoolSize);
-
+
public boolean resizeQueue(int capacity);
-
+
}
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java?rev=1200171&r1=1200170&r2=1200171&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java Thu Nov 10 05:55:40 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,9 +23,9 @@ import java.util.concurrent.TimeUnit;
/**
* As task queue specifically designed to run with a thread pool executor.
- * The task queue is optimised to properly utilize threads within
+ * The task queue is optimised to properly utilize threads within
* a thread pool executor. If you use a normal queue, the executor will spawn threads
- * when there are idle threads and you wont be able to force items unto the queue itself
+ * when there are idle threads and you wont be able to force items unto the queue itself
* @author fhanik
*
*/
@@ -34,7 +34,7 @@ public class TaskQueue extends LinkedBlo
private static final long serialVersionUID = 1L;
private ThreadPoolExecutor parent = null;
-
+
// no need to be volatile, the one times when we change and read it occur in
// a single thread (the one that did stop a context and fired listeners)
private Integer forcedRemainingCapacity = null;
@@ -54,7 +54,7 @@ public class TaskQueue extends LinkedBlo
public void setParent(ThreadPoolExecutor tp) {
parent = tp;
}
-
+
public boolean force(Runnable o) {
if ( parent.isShutdown() ) throw new RejectedExecutionException("Executor not running, can't force a command into the queue");
return super.offer(o); //forces the item onto the queue, to be used if the task is rejected
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThread.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThread.java?rev=1200171&r1=1200170&r2=1200171&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThread.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThread.java Thu Nov 10 05:55:40 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +18,7 @@ package org.apache.tomcat.util.threads;
/**
* A Thread implementation that records the time at which it was created.
- *
+ *
*/
public class TaskThread extends Thread {
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java?rev=1200171&r1=1200170&r2=1200171&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java Thu Nov 10 05:55:40 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java?rev=1200171&r1=1200170&r2=1200171&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/threads/ThreadPoolExecutor.java Thu Nov 10 05:55:40 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -83,7 +83,7 @@ public class ThreadPoolExecutor extends
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, new RejectHandler());
}
-
+
public long getThreadRenewalDelay() {
return threadRenewalDelay;
}
@@ -131,12 +131,12 @@ public class ThreadPoolExecutor extends
}
}
}
-
+
protected boolean currentThreadShouldBeStopped() {
if (threadRenewalDelay >= 0
&& Thread.currentThread() instanceof TaskThread) {
TaskThread currentTaskThread = (TaskThread) Thread.currentThread();
- if (currentTaskThread.getCreationTime() <
+ if (currentTaskThread.getCreationTime() <
this.lastContextStoppedTime.longValue()) {
return true;
}
@@ -147,7 +147,7 @@ public class ThreadPoolExecutor extends
public int getSubmittedCount() {
return submittedCount.get();
}
-
+
/**
* {@inheritDoc}
*/
@@ -155,14 +155,14 @@ public class ThreadPoolExecutor extends
public void execute(Runnable command) {
execute(command,0,TimeUnit.MILLISECONDS);
}
-
+
/**
* Executes the given command at some time in the future. The command
* may execute in a new thread, in a pooled thread, or in the calling
* thread, at the discretion of the <tt>Executor</tt> implementation.
* If no threads are available, it will be added to the work queue.
- * If the work queue is full, the system will wait for the specified
- * time and it throw a RejectedExecutionException if the queue is still
+ * If the work queue is full, the system will wait for the specified
+ * time and it throw a RejectedExecutionException if the queue is still
* full after that.
*
* @param command the runnable task
@@ -191,7 +191,7 @@ public class ThreadPoolExecutor extends
submittedCount.decrementAndGet();
throw rx;
}
-
+
}
}
@@ -218,7 +218,7 @@ public class ThreadPoolExecutor extends
// queue.take())
// even if we did not wait enough, TaskQueue.take() takes care of timing
// out, so that we are sure that all threads of the pool are renewed in
- // a limited time, something like
+ // a limited time, something like
// (threadKeepAlive + longest request time)
try {
Thread.sleep(200L);
@@ -232,14 +232,14 @@ public class ThreadPoolExecutor extends
}
this.setCorePoolSize(savedCorePoolSize);
}
-
+
private static class RejectHandler implements RejectedExecutionHandler {
@Override
public void rejectedExecution(Runnable r,
java.util.concurrent.ThreadPoolExecutor executor) {
throw new RejectedExecutionException();
}
-
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org