use of com.google.j2objc.annotations.WeakOuter in project guava by google.
the class AbstractScheduledService method executor.
/**
* Returns the {@link ScheduledExecutorService} that will be used to execute the {@link #startUp},
* {@link #runOneIteration} and {@link #shutDown} methods. If this method is overridden the
* executor will not be {@linkplain ScheduledExecutorService#shutdown shutdown} when this service
* {@linkplain Service.State#TERMINATED terminates} or {@linkplain Service.State#TERMINATED
* fails}. Subclasses may override this method to supply a custom {@link ScheduledExecutorService}
* instance. This method is guaranteed to only be called once.
*
* <p>By default this returns a new {@link ScheduledExecutorService} with a single thread thread
* pool that sets the name of the thread to the {@linkplain #serviceName() service name}. Also,
* the pool will be {@linkplain ScheduledExecutorService#shutdown() shut down} when the service
* {@linkplain Service.State#TERMINATED terminates} or {@linkplain Service.State#TERMINATED
* fails}.
*/
protected ScheduledExecutorService executor() {
@WeakOuter
class ThreadFactoryImpl implements ThreadFactory {
@Override
public Thread newThread(Runnable runnable) {
return MoreExecutors.newThread(serviceName(), runnable);
}
}
final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl());
// Add a listener to shutdown the executor after the service is stopped. This ensures that the
// JVM shutdown will not be prevented from exiting after this service has stopped or failed.
// Technically this listener is added after start() was called so it is a little gross, but it
// is called within doStart() so we know that the service cannot terminate or fail concurrently
// with adding this listener so it is impossible to miss an event that we are interested in.
addListener(new Listener() {
@Override
public void terminated(State from) {
executor.shutdown();
}
@Override
public void failed(State from, Throwable failure) {
executor.shutdown();
}
}, directExecutor());
return executor;
}
use of com.google.j2objc.annotations.WeakOuter in project j2objc by google.
the class InnerClassExtractor method endHandleType.
private void endHandleType(AbstractTypeDeclaration node) {
int insertIdx = typeOrderStack.remove(typeOrderStack.size() - 1);
TreeNode parentNode = node.getParent();
if (!(parentNode instanceof CompilationUnit)) {
// Remove this type declaration from its current location.
node.remove();
if (parentNode instanceof TypeDeclarationStatement) {
parentNode.remove();
}
addCaptureFields(node);
// Make this node non-private, if necessary, and add it to the unit's type
// list.
node.removeModifiers(Modifier.PRIVATE);
unitTypes.add(insertIdx, node);
// Check for erroneous WeakOuter annotation on static inner class.
TypeElement type = node.getTypeElement();
if (ElementUtil.isStatic(type) && ElementUtil.hasAnnotation(type, WeakOuter.class)) {
ErrorUtil.warning("static class " + type.getQualifiedName() + " has WeakOuter annotation");
}
}
}
Aggregations