From b8f29d3c30ae2c2a1efffa98cff2a5e60363fae6 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Mon, 4 May 2015 12:42:28 +0200
Subject: [PATCH] fixed #149 Move getNumWaits to IMonitoringPipe; moved test
 framework classes to src/main/java;

---
 .settings/edu.umd.cs.findbugs.core.prefs          |  2 +-
 .../teetime/framework/pipe/IMonitorablePipe.java  |  6 ++++++
 .../java/teetime/framework/pipe/SpScPipe.java     |  6 +++---
 .../java/teetime/util/CyclicListIterator.java     | 12 ++++++------
 src/main/java/teetime/util/ListUtil.java          |  8 ++++----
 .../AbstractProfiledPerformanceAssertion.java     |  2 +-
 .../test/framework}/MeasurementRepository.java    |  2 +-
 .../PerformanceCheckProfileRepository.java        |  2 +-
 .../util/test/framework}/PerformanceTest.java     |  2 +-
 src/site/markdown/wiki                            |  2 +-
 .../framework/pipe/SingleElementPipeTest.java     | 15 +++++++++++++++
 11 files changed, 40 insertions(+), 19 deletions(-)
 rename src/{test/java/util/test => main/java/teetime/util/test/framework}/AbstractProfiledPerformanceAssertion.java (95%)
 rename src/{test/java/util/test => main/java/teetime/util/test/framework}/MeasurementRepository.java (96%)
 rename src/{test/java/util/test => main/java/teetime/util/test/framework}/PerformanceCheckProfileRepository.java (98%)
 rename src/{test/java/util/test => main/java/teetime/util/test/framework}/PerformanceTest.java (98%)

diff --git a/.settings/edu.umd.cs.findbugs.core.prefs b/.settings/edu.umd.cs.findbugs.core.prefs
index d38ed3fa..ebe54a3d 100644
--- a/.settings/edu.umd.cs.findbugs.core.prefs
+++ b/.settings/edu.umd.cs.findbugs.core.prefs
@@ -1,5 +1,5 @@
 #FindBugs User Preferences
-#Thu Apr 30 18:04:06 CEST 2015
+#Mon May 04 12:38:24 CEST 2015
 detector_threshold=3
 effort=max
 excludefilter0=.fbExcludeFilterFile|true
diff --git a/src/main/java/teetime/framework/pipe/IMonitorablePipe.java b/src/main/java/teetime/framework/pipe/IMonitorablePipe.java
index a0c6a245..12bec8a4 100644
--- a/src/main/java/teetime/framework/pipe/IMonitorablePipe.java
+++ b/src/main/java/teetime/framework/pipe/IMonitorablePipe.java
@@ -26,4 +26,10 @@ public interface IMonitorablePipe {
 	long getPushThroughput();
 
 	long getPullThroughput();
+
+	/**
+	 *
+	 * @return the number of pauses of the pushing stage
+	 */
+	int getNumWaits();
 }
diff --git a/src/main/java/teetime/framework/pipe/SpScPipe.java b/src/main/java/teetime/framework/pipe/SpScPipe.java
index ab91207d..4c1e52ae 100644
--- a/src/main/java/teetime/framework/pipe/SpScPipe.java
+++ b/src/main/java/teetime/framework/pipe/SpScPipe.java
@@ -35,7 +35,7 @@ final class SpScPipe extends AbstractInterThreadPipe implements IMonitorablePipe
 	}
 
 	@Deprecated
-	public static <T> SpScPipe connect(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
+	public static <T> IMonitorablePipe connect(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
 		final SpScPipe pipe = new SpScPipe(sourcePort, targetPort, capacity);
 		pipe.connectPorts(sourcePort, targetPort);
 		return pipe;
@@ -81,8 +81,8 @@ final class SpScPipe extends AbstractInterThreadPipe implements IMonitorablePipe
 		return this.queue.size();
 	}
 
-	// BETTER find a solution w/o any thread-safe code in this stage
-	public synchronized int getNumWaits() {
+	@Override
+	public int getNumWaits() {
 		return this.numWaits;
 	}
 
diff --git a/src/main/java/teetime/util/CyclicListIterator.java b/src/main/java/teetime/util/CyclicListIterator.java
index 53965942..1579d5d3 100644
--- a/src/main/java/teetime/util/CyclicListIterator.java
+++ b/src/main/java/teetime/util/CyclicListIterator.java
@@ -27,13 +27,13 @@ import java.util.List;
  */
 public final class CyclicListIterator<T> implements Iterator<T> {
 
-	private final List<T> list;
+	private final List<T> elements;
 	// private Iterator<T> iterator;
 
 	private int currentIndex = 0;
 
-	public CyclicListIterator(final List<T> list) {
-		this.list = list;
+	public CyclicListIterator(final List<T> elements) {
+		this.elements = elements;
 		// this.iterator = this.list.iterator();
 	}
 
@@ -53,7 +53,7 @@ public final class CyclicListIterator<T> implements Iterator<T> {
 		// <li>an index overflow (then restart from index 0), or
 		// <li>an add() or a remove(), so update the index
 		this.currentIndex = this.getCurrentIndex();
-		final T element = this.list.get(this.currentIndex);
+		final T element = this.elements.get(this.currentIndex);
 		this.currentIndex++;
 		return element;
 	}
@@ -62,11 +62,11 @@ public final class CyclicListIterator<T> implements Iterator<T> {
 	public void remove() {
 		// this.iterator.remove();
 		this.currentIndex = this.getCurrentIndex();
-		this.list.remove(this.currentIndex);
+		this.elements.remove(this.currentIndex);
 	}
 
 	private int getCurrentIndex() {
-		return this.currentIndex % this.list.size();
+		return this.currentIndex % this.elements.size();
 	}
 
 }
diff --git a/src/main/java/teetime/util/ListUtil.java b/src/main/java/teetime/util/ListUtil.java
index 6ae6fea4..2e4074c5 100644
--- a/src/main/java/teetime/util/ListUtil.java
+++ b/src/main/java/teetime/util/ListUtil.java
@@ -25,12 +25,12 @@ public final class ListUtil {
 	}
 
 	public static <T> List<T> merge(final List<List<T>> listOfLists) {
-		List<T> resultList = listOfLists.get(0);
+		List<T> mergedElements = listOfLists.get(0);
 		for (int i = 1; i < listOfLists.size(); i++) {
-			Collection<? extends T> timestampObjectList = listOfLists.get(i);
-			resultList.addAll(timestampObjectList);
+			Collection<? extends T> elements = listOfLists.get(i);
+			mergedElements.addAll(elements);
 		}
-		return resultList;
+		return mergedElements;
 	}
 
 	public static <T> List<T> removeFirstHalfElements(final List<T> list) {
diff --git a/src/test/java/util/test/AbstractProfiledPerformanceAssertion.java b/src/main/java/teetime/util/test/framework/AbstractProfiledPerformanceAssertion.java
similarity index 95%
rename from src/test/java/util/test/AbstractProfiledPerformanceAssertion.java
rename to src/main/java/teetime/util/test/framework/AbstractProfiledPerformanceAssertion.java
index e5981c58..60afa855 100644
--- a/src/test/java/util/test/AbstractProfiledPerformanceAssertion.java
+++ b/src/main/java/teetime/util/test/framework/AbstractProfiledPerformanceAssertion.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package util.test;
+package teetime.util.test.framework;
 
 public abstract class AbstractProfiledPerformanceAssertion {
 
diff --git a/src/test/java/util/test/MeasurementRepository.java b/src/main/java/teetime/util/test/framework/MeasurementRepository.java
similarity index 96%
rename from src/test/java/util/test/MeasurementRepository.java
rename to src/main/java/teetime/util/test/framework/MeasurementRepository.java
index e19fe7a6..be3552b8 100644
--- a/src/test/java/util/test/MeasurementRepository.java
+++ b/src/main/java/teetime/util/test/framework/MeasurementRepository.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package util.test;
+package teetime.util.test.framework;
 
 import java.util.HashMap;
 import java.util.Map;
diff --git a/src/test/java/util/test/PerformanceCheckProfileRepository.java b/src/main/java/teetime/util/test/framework/PerformanceCheckProfileRepository.java
similarity index 98%
rename from src/test/java/util/test/PerformanceCheckProfileRepository.java
rename to src/main/java/teetime/util/test/framework/PerformanceCheckProfileRepository.java
index fbefc401..a3ee2c71 100644
--- a/src/test/java/util/test/PerformanceCheckProfileRepository.java
+++ b/src/main/java/teetime/util/test/framework/PerformanceCheckProfileRepository.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package util.test;
+package teetime.util.test.framework;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
diff --git a/src/test/java/util/test/PerformanceTest.java b/src/main/java/teetime/util/test/framework/PerformanceTest.java
similarity index 98%
rename from src/test/java/util/test/PerformanceTest.java
rename to src/main/java/teetime/util/test/framework/PerformanceTest.java
index 0bb3c3fe..813ffc69 100644
--- a/src/test/java/util/test/PerformanceTest.java
+++ b/src/main/java/teetime/util/test/framework/PerformanceTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package util.test;
+package teetime.util.test.framework;
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/src/site/markdown/wiki b/src/site/markdown/wiki
index bb53dfd7..0e447457 160000
--- a/src/site/markdown/wiki
+++ b/src/site/markdown/wiki
@@ -1 +1 @@
-Subproject commit bb53dfd7de974a433a7b96b0b65f4aacb8da3df3
+Subproject commit 0e4474577e1f49bc96e734c286b2d9e0363895e8
diff --git a/src/test/java/teetime/framework/pipe/SingleElementPipeTest.java b/src/test/java/teetime/framework/pipe/SingleElementPipeTest.java
index 415ef503..07b869fa 100644
--- a/src/test/java/teetime/framework/pipe/SingleElementPipeTest.java
+++ b/src/test/java/teetime/framework/pipe/SingleElementPipeTest.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime.sourceforge.net)
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package teetime.framework.pipe;
 
 import static org.junit.Assert.assertFalse;
-- 
GitLab