[New] added StrolchAgent.getSingleThreadExecutor()

This commit is contained in:
Robert von Burg 2018-10-15 14:36:56 +02:00
parent 21aa92182c
commit cee1ac4f82
2 changed files with 43 additions and 2 deletions

View File

@ -104,6 +104,26 @@ public class StrolchAgent {
return executor;
}
/**
* Return the {@link ExecutorService} instantiated for this agent
*
* @return the {@link ExecutorService} instantiated for this agent
*/
public ExecutorService getSingleThreadExecutor() {
return getSingleThreadExecutor("Agent");
}
public synchronized ExecutorService getSingleThreadExecutor(String poolName) {
DBC.PRE.assertNotEmpty("poolName must be set!", poolName);
ExecutorService executor = this.executors.get(poolName);
if (executor == null) {
executor = Executors.newSingleThreadExecutor(new ThreadPoolFactory(poolName));
this.executors.put(poolName, executor);
}
return executor;
}
/**
* Return the {@link ScheduledExecutorService} instantiated for this agent
*
@ -125,8 +145,8 @@ public class StrolchAgent {
}
/**
* Initializes the underlying container and prepares the executor services. Before calling this method,
* {@link #setup(String, File, File, File)} must have ben called
* Initializes the underlying container and prepares the executor services. Before calling this method, {@link
* #setup(String, File, File, File)} must have ben called
*/
public void initialize() {
if (this.container == null)

View File

@ -136,6 +136,27 @@ public class StrolchComponent {
return this.container.getAgent().getExecutor(poolName);
}
/**
* Return the {@link ExecutorService} instantiated for this agent
*
* @return the {@link ExecutorService} instantiated for this agent
*/
protected ExecutorService getSingleThreadExecutor() {
return this.container.getAgent().getSingleThreadExecutor();
}
/**
* Return the {@link ExecutorService} for the given poolName instantiated for this agent
*
* @param poolName
* the name of the pool
*
* @return the {@link ExecutorService} for the given poolName instantiated for this agent
*/
protected ExecutorService getSingleThreadExecutor(String poolName) {
return this.container.getAgent().getSingleThreadExecutor(poolName);
}
/**
* Return the {@link ScheduledExecutorService} instantiated for this agent
*