From 5d3ab08c4e5333db78a44be216f5f6ae5b6321f3 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Wed, 11 Mar 2015 16:47:16 +0100
Subject: [PATCH] added SpScIntraThreadPipeFactory

---
 .../framework/pipe/SpScIntraThreadPipe.java   | 17 ++++++-
 .../pipe/SpScIntraThreadPipeFactory.java      | 50 +++++++++++++++++++
 2 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 src/main/java/teetime/framework/pipe/SpScIntraThreadPipeFactory.java

diff --git a/src/main/java/teetime/framework/pipe/SpScIntraThreadPipe.java b/src/main/java/teetime/framework/pipe/SpScIntraThreadPipe.java
index 459ea0f1..5f3c71c7 100644
--- a/src/main/java/teetime/framework/pipe/SpScIntraThreadPipe.java
+++ b/src/main/java/teetime/framework/pipe/SpScIntraThreadPipe.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2015 TeeTime (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 java.util.Queue;
@@ -20,7 +35,7 @@ public final class SpScIntraThreadPipe<T> extends AbstractIntraThreadPipe {
 
 	private final Queue<Object> queue;
 
-	public SpScIntraThreadPipe(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) {
+	SpScIntraThreadPipe(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) {
 		super(sourcePort, targetPort);
 		queue = QueueFactory.newQueue(ConcurrentQueueSpec.createBoundedSpsc(1));
 	}
diff --git a/src/main/java/teetime/framework/pipe/SpScIntraThreadPipeFactory.java b/src/main/java/teetime/framework/pipe/SpScIntraThreadPipeFactory.java
new file mode 100644
index 00000000..8725cf18
--- /dev/null
+++ b/src/main/java/teetime/framework/pipe/SpScIntraThreadPipeFactory.java
@@ -0,0 +1,50 @@
+/**
+ * Copyright (C) 2015 TeeTime (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 teetime.framework.InputPort;
+import teetime.framework.OutputPort;
+import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
+import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
+
+public final class SpScIntraThreadPipeFactory implements IPipeFactory {
+
+	@Override
+	public <T> IPipe create(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) {
+		return this.create(sourcePort, targetPort, 4);
+	}
+
+	@Override
+	public <T> IPipe create(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
+		return new SpScIntraThreadPipe<T>(sourcePort, targetPort);
+	}
+
+	@Override
+	public ThreadCommunication getThreadCommunication() {
+		return ThreadCommunication.INTRA;
+	}
+
+	@Override
+	public PipeOrdering getOrdering() {
+		return PipeOrdering.QUEUE_BASED;
+	}
+
+	@Override
+	public boolean isGrowable() {
+		return false;
+	}
+
+}
-- 
GitLab