Java 类com.google.common.util.concurrent.Atomics 实例源码

项目:framer    文件:Device.java   
@Nullable
private String queryMountPoint(@NonNull final String name)
        throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException {

    final AtomicReference<String> ref = Atomics.newReference();
    executeShellCommand("echo $" + name, new MultiLineReceiver() { //$NON-NLS-1$
        @Override
        public boolean isCancelled() {
            return false;
        }

        @Override
        public void processNewLines(String[] lines) {
            for (String line : lines) {
                if (!line.isEmpty()) {
                    // this should be the only one.
                    ref.set(line);
                }
            }
        }
    });
    return ref.get();
}
项目:intellij-ce-playground    文件:AnnotationsRenderer.java   
@NotNull
private static Result renderIntDefAnnotation(@NotNull final PsiAnnotation annotation, final int value) {
  final AtomicReference<AndroidResolveHelper.IntDefResolution> valuesRef = Atomics.newReference();

  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      valuesRef.set(AndroidResolveHelper.resolveIntDef(annotation));
    }
  });

  AndroidResolveHelper.IntDefResolution intDef = valuesRef.get();
  if (intDef.valuesMap == null) {
    renderUnknown("IntDef", value);
  }

  return new Result(String.format(Locale.US, "0x%1$08x {%2$s}", value, renderIntDef(value, intDef)), null);
}
项目:gerrit    文件:SuExec.java   
@Inject
SuExec(
    final SshScope sshScope,
    @CommandName(Commands.ROOT) final DispatchCommandProvider dispatcher,
    PermissionBackend permissionBackend,
    final CurrentUser caller,
    final SshSession session,
    final IdentifiedUser.GenericFactory userFactory,
    final SshScope.Context callingContext,
    AuthConfig config) {
  this.sshScope = sshScope;
  this.dispatcher = dispatcher;
  this.permissionBackend = permissionBackend;
  this.caller = caller;
  this.session = session;
  this.userFactory = userFactory;
  this.callingContext = callingContext;
  this.enableRunAs = config.isRunAsEnabled();
  atomicCmd = Atomics.newReference();
}
项目:stratos    文件:AWSEC2ComputeServiceContextModule.java   
@Provides
@Singleton
protected Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader(
         final RegionAndIdToImage delegate) {
   return Suppliers.<CacheLoader<RegionAndName, Image>>ofInstance(new CacheLoader<RegionAndName, Image>() {
      private final AtomicReference<AuthorizationException> authException = Atomics.newReference();

      @Override
      public Image load(final RegionAndName key) throws Exception {
         // raw lookup of an image
         Supplier<Image> rawSupplier = new Supplier<Image>() {
            @Override public Image get() {
               try {
                  return delegate.load(key);
               } catch (ExecutionException e) {
                  throw Throwables.propagate(e);
               }
            }
         };
         return new SetAndThrowAuthorizationExceptionSupplier<Image>(rawSupplier, authException).get();
      }

   });
}
项目:Mastering-Mesos    文件:Recovery.java   
@Inject
RecoveryImpl(
    File backupDir,
    Function<Snapshot, TemporaryStorage> tempStorageFactory,
    Storage primaryStorage,
    DistributedSnapshotStore distributedStore,
    Command shutDownNow) {

  this.backupDir = requireNonNull(backupDir);
  this.tempStorageFactory = requireNonNull(tempStorageFactory);
  this.recovery = Atomics.newReference();
  this.primaryStorage = requireNonNull(primaryStorage);
  this.distributedStore = requireNonNull(distributedStore);
  this.shutDownNow = requireNonNull(shutDownNow);
}
项目:intellij-ce-playground    文件:AndroidStudioWelcomeScreenProvider.java   
@Nullable
private static ConnectionState promptToRetryFailedConnection() {
  final AtomicReference<ConnectionState> atomicBoolean = Atomics.newReference();
  Application application = ApplicationManager.getApplication();
  application.invokeAndWait(new Runnable() {
    @Override
    public void run() {
      atomicBoolean.set(promptUserForProxy());
    }
  }, application.getAnyModalityState());
  return atomicBoolean.get();
}
项目:plugins_replication    文件:OnStartStop.java   
@Inject
protected OnStartStop(
    ServerInformation srvInfo,
    PushAll.Factory pushAll,
    ReplicationQueue queue,
    ReplicationConfig config,
    DynamicItem<EventDispatcher> eventDispatcher) {
  this.srvInfo = srvInfo;
  this.pushAll = pushAll;
  this.queue = queue;
  this.config = config;
  this.eventDispatcher = eventDispatcher;
  this.pushAllFuture = Atomics.newReference();
}
项目:gerrit    文件:DispatchCommand.java   
@Inject
DispatchCommand(
    CurrentUser user,
    PermissionBackend permissionBackend,
    @Assisted Map<String, CommandProvider> all) {
  this.currentUser = user;
  this.permissionBackend = permissionBackend;
  commands = all;
  atomicCmd = Atomics.newReference();
}
项目:gerrit    文件:AliasCommand.java   
AliasCommand(
    @CommandName(Commands.ROOT) DispatchCommandProvider root,
    PermissionBackend permissionBackend,
    CurrentUser currentUser,
    CommandName command) {
  this.root = root;
  this.permissionBackend = permissionBackend;
  this.currentUser = currentUser;
  this.command = command;
  this.atomicCmd = Atomics.newReference();
}
项目:stratos    文件:GCEIaas.java   
private Operation waitGCEOperationDone(Operation operation) {
    IaasProvider iaasInfo = getIaasProvider();
    Injector injector = ContextBuilder.newBuilder(iaasInfo.getProvider())
            .credentials(iaasInfo.getIdentity(), iaasInfo.getCredential())
            .buildInjector();
    Predicate<AtomicReference<Operation>> zoneOperationDonePredicate =
            injector.getInstance(Key.get(new TypeLiteral<Predicate<AtomicReference<Operation>>>() {
            }, Names.named("zone")));
    AtomicReference<Operation> operationReference = Atomics.newReference(operation);
    retry(zoneOperationDonePredicate, MAX_WAIT_TIME, 1, SECONDS).apply(operationReference);

    return operationReference.get();
}
项目:pdef-java    文件:RpcProtocolTest.java   
@Test
public void testGetRequest() throws Exception {
    AtomicReference<Invocation> ref = Atomics.newReference();
    proxy(ref).method(1, 2);

    RpcRequest request = protocol.getRequest(ref.get());
    assertEquals(RpcRequest.GET, request.getMethod());
    assertEquals("/method", request.getRelativePath());
    assertEquals(ImmutableMap.of("arg0", "1", "arg1", "2"), request.getQuery());
    assertTrue(request.getPost().isEmpty());
}
项目:pdef-java    文件:RpcProtocolTest.java   
@Test
public void testGetRequest_query() throws Exception {
    AtomicReference<Invocation> ref = Atomics.newReference();
    proxy(ref).query(1, 2);

    RpcRequest request = protocol.getRequest(ref.get());
    assertEquals("/query", request.getRelativePath());
    assertEquals(ImmutableMap.of("arg0", "1", "arg1", "2"), request.getQuery());
    assertTrue(request.getPost().isEmpty());
}
项目:pdef-java    文件:RpcProtocolTest.java   
@Test
public void testGetRequest_post() throws Exception {
    AtomicReference<Invocation> ref = Atomics.newReference();
    proxy(ref).post(1, 2);

    RpcRequest request = protocol.getRequest(ref.get());
    assertEquals(RpcRequest.POST, request.getMethod());
    assertEquals("/post", request.getRelativePath());
    assertTrue(request.getQuery().isEmpty());
    assertEquals(ImmutableMap.of("arg0", "1", "arg1", "2"), request.getPost());
}
项目:pdef-java    文件:RpcProtocolTest.java   
@Test
public void testGetRequest_chainedMethods() throws Exception {
    AtomicReference<Invocation> ref = Atomics.newReference();
    proxy(ref).interface0(1, 2).method(3, 4);

    RpcRequest request = protocol.getRequest(ref.get());
    assertEquals(RpcRequest.GET, request.getMethod());
    assertEquals("/interface0/1/2/method", request.getRelativePath());
    assertEquals(ImmutableMap.of("arg0", "3", "arg1", "4"), request.getQuery());
    assertTrue(request.getPost().isEmpty());
}
项目:pdef-java    文件:RpcProtocolTest.java   
@Test
public void testGetRequest_urlencodeArgs() throws Exception {
    AtomicReference<Invocation> ref = Atomics.newReference();
    proxy(ref).interface0(1, 2).string0("привет");

    RpcRequest request = protocol.getRequest(ref.get());
    assertEquals("/interface0/1/2/string0", request.getRelativePath());
}
项目:gerrit    文件:BaseCommand.java   
public BaseCommand() {
  task = Atomics.newReference();
}
项目:gerrit    文件:CommandFactoryProvider.java   
Trampoline(String cmdLine) {
  commandLine = cmdLine;
  argv = split(cmdLine);
  logged = new AtomicBoolean();
  task = Atomics.newReference();
}