Skip to content
Snippets Groups Projects
Commit 8932c0b4 authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

Changed interface

Javadoc
parent 16730255
No related branches found
No related tags found
No related merge requests found
package teetime.framework;
public abstract class AbstractService<T> {
abstract void merge(T target, T source);
}
package teetime.framework;
public interface IService {
public void merge(IService first, IService second);
}
...@@ -14,7 +14,13 @@ import teetime.framework.signal.InitializingSignal; ...@@ -14,7 +14,13 @@ import teetime.framework.signal.InitializingSignal;
import teetime.util.ThreadThrowableContainer; import teetime.util.ThreadThrowableContainer;
import teetime.util.framework.concurrent.SignalingCounter; import teetime.util.framework.concurrent.SignalingCounter;
class ThreadService implements IService { /**
* A Service which manages thread creation and running.
*
* @author Nelson Tavares de Sousa
*
*/
class ThreadService extends AbstractService<ThreadService> {
private Map<Stage, String> threadableStages = new HashMap<Stage, String>(); private Map<Stage, String> threadableStages = new HashMap<Stage, String>();
...@@ -75,7 +81,7 @@ class ThreadService implements IService { ...@@ -75,7 +81,7 @@ class ThreadService implements IService {
return thread; return thread;
} }
public void addThreadableStage(final Stage stage, final String threadName) { void addThreadableStage(final Stage stage, final String threadName) {
if (this.threadableStages.put(stage, threadName) != null) { if (this.threadableStages.put(stage, threadName) != null) {
LOGGER.warn("Stage " + stage.getId() + " was already marked as threadable stage."); LOGGER.warn("Stage " + stage.getId() + " was already marked as threadable stage.");
} }
...@@ -145,12 +151,7 @@ class ThreadService implements IService { ...@@ -145,12 +151,7 @@ class ThreadService implements IService {
} }
} }
@Override Map<Stage, String> getThreadableStages() {
public void merge(final IService first, final IService second) {
}
public Map<Stage, String> getThreadableStages() {
return threadableStages; return threadableStages;
} }
...@@ -158,4 +159,10 @@ class ThreadService implements IService { ...@@ -158,4 +159,10 @@ class ThreadService implements IService {
this.threadableStages = threadableStages; this.threadableStages = threadableStages;
} }
@Override
void merge(final ThreadService target, final ThreadService source) {
// TODO Auto-generated method stub
}
} }
/**
* Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime)
*
* 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;
public class ThreadServiceB {
public Runnable startWithinNewThread(final Stage stage) {
Runnable runnable = wrap(stage);
Thread thread = new Thread(runnable);
thread.start();
return runnable;
}
private AbstractRunnableStage wrap(final Stage stage) {
if (stage.getInputPorts().size() > 0) {
return new RunnableConsumerStage(stage);
}
return new RunnableProducerStage(stage);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment