diff --git a/src/main/java/teetime/framework/pipe/SpScIntraThreadPipe.java b/src/main/java/teetime/framework/pipe/SpScIntraThreadPipe.java index 459ea0f17f276ae33b273b91300b6907c58b7386..5f3c71c7caf9b624dafa0bd8bc9761ecc67abbb5 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 0000000000000000000000000000000000000000..8725cf18c637d1f28ebc28c9e926eb5fae6f33a2 --- /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; + } + +}