jadex.base.test.impl.SharedThreadPoolService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform-bridge Show documentation
Show all versions of jadex-platform-bridge Show documentation
Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.
package jadex.base.test.impl;
import jadex.bridge.IComponentIdentifier;
import jadex.bridge.service.types.threadpool.IThreadPoolService;
import jadex.commons.IChangeListener;
/**
* Helper class to allow sharing a thread pool service across platforms in same VM.
*/
public class SharedThreadPoolService extends SharedService implements IThreadPoolService
{
/**
* Get the instance.
*/
public SharedThreadPoolService(IComponentIdentifier provider, SharedServiceFactory factory)
{
super(provider, IThreadPoolService.class, factory);
}
//-------- IThreadPool interface --------
@Override
public void execute(Runnable task)
{
getInstance().execute(task);
}
@Override
public void executeForever(Runnable task)
{
getInstance().executeForever(task);
}
@Override
public void dispose()
{
// IThreadPool method -> Should not be called on service
throw new UnsupportedOperationException("Service shut be terminated via shutdown!");
}
@Override
public boolean isRunning()
{
return getInstance().isRunning();
}
@Override
public void addFinishListener(IChangeListener listener)
{
getInstance().addFinishListener(listener);
}
}