Retrieves the result for the specified listener.  If the result is already available (or the
request failed), the listener will receive an immediate response.  Otherwise, the listener
will be added to the list and notified when the result is available.
355721
public void getResult (ResultListener<T> rl)
    {
        if (_error != null) {
            rl.requestFailed(_error);
        } else if (_list == null) { // _list == null when we have a result
            rl.requestCompleted(_result);
        } else {
            _list.add(rl);
        }
    }
1326377
private <T extends Rdp4jListener> void notifyListeners(Class<T> listenerType, Notifier<T> notifier)
            throws InterruptedException {
        for (Rdp4jListener listener : listeners) {
            if (isInstanceOf(listener, listenerType)) {
                /*
                 * This cast is correct, since we check if listener
                 * is instance of listenerType.
                 */
                @SuppressWarnings("unchecked")
                T listener2 = (T) listener;
                try {
                    notifier.notify(listener2);
                } catch (InterruptedException e) {
                    throw e;
                } catch (Throwable e) {
                    logErrorMessage(e);
                }
            }
        }
    }
764829
def send_result(self, result):
        
        response_data = self._client.upload_results(result)
        if response_data:
            if self.logger is not None:
                self.logger.info("Results sent to the server. ID: {}".format(response_data["_id"]))
            return response_data
        else:
            if self.logger is not None:
                self.logger.info("Server didn't respond or client initialization has failed.")
            return None
1315549
public void execute(ChannelQueryListener listener) {
		addChannelQueryListener(listener);
		
		// Make a local copy to avoid synchronization
		Result localResult = result;
		
		// If the query was executed, just call the listener
		if (localResult != null) {
			listener.queryExecuted(localResult);
		} else {
			execute();
		}
		
	}
955342
public Future<V> submit(Runnable task, V result) {
        if (task == null) throw new NullPointerException();
        NotifyingFuture<V> f = executor.submit(task, result);
        f.setListener(listener);
        return f;
    }
71938
def add_listener(self, listener, question):
        """"""
        now = current_time_millis()
        self.listeners.append(listener)
        if question is not None:
            for record in self.cache.entries_with_name(question.name):
                if question.answered_by(record) and not record.is_expired(now):
                    listener.update_record(self, now, record)
        self.notify_all()
899202
public void handleSuccess ()
    {
        if (_listener instanceof InvocationService.ConfirmListener) {
            reportRequestProcessed();
        } else if (_listener instanceof InvocationService.ResultListener && _resultSet) {
            reportRequestProcessed(_result);
        }
    }
328848
def run_listener(listener)
      retry_count = 0

      begin
        listener.start
      rescue Exception => e
        handle_crashed_listener(listener, e, retry_count)
        retry_count += 1
        retry unless @signal_to_stop
      end
    rescue Exception => e
      log_error("Failed to run listener (#{e.message})", error_metadata(e))
      raise e
    end
623631
@Override
  public void initializeListener(QueryBatcher queryBatcher) {
    HostAvailabilityListener hostAvailabilityListener = HostAvailabilityListener.getInstance(queryBatcher);
    if ( hostAvailabilityListener != null ) {
      BatchFailureListener<QueryBatch> retryListener = hostAvailabilityListener.initializeRetryListener(this);
      if( retryListener != null )  onFailure(retryListener);
    }
  }
507797
public void addListener(EventListener l) {
        if (l == null) {
            throw new NullPointerException();
        }

        if (acceptsListener(l)) {
            synchronized (notifyLock) {
                if (listeners == null) {
                    listeners = new ArrayList<EventListener>();
                } else {
                    // identity equality check
                    for (EventListener ll : listeners) {
                        if (ll == l) {
                            return;
                        }
                    }
                }

                listeners.add(l);
            }
        } else {
            throw new IllegalStateException("Listener invalid for this notifier.");
        }
    }
711847
public void acquireLock (final NodeObject.Lock lock, final ResultListener<String> listener)
    {
        // wait until any pending resolution is complete
        queryLock(lock, new ChainedResultListener<String, String>(listener) {
            public void requestCompleted (String result) {
                if (result == null) {
                    if (_suboids.isEmpty()) {
                        lockAcquired(lock, 0L, listener);
                    } else {
                        _locks.put(lock, new LockHandler(lock, true, listener));
                    }
                } else {
                    listener.requestCompleted(result);
                }
            }
        });
    }
97844
def get_listener(name):
    '''
    
    '''
    try:
        log.debug('Using %s as listener', name)
        return LISTENER_LOOKUP[name]
    except KeyError:
        msg = 'Listener {} is not available. Are the dependencies installed?'.format(name)
        log.error(msg, exc_info=True)
        raise InvalidListenerException(msg)
625473
public void setResult(E result) {
        boolean fireListeners = false;
        if (!isDone()) {
            fireListeners = this.result.compareAndSet(null, result);
            synchronized (this) {
                if (waiters > 0) {
                    notifyAll();
                }
            }
                
        }
        if (fireListeners) {
            notifyListeners();
        }
        
    	
    }
986349
void updateListenersWithFailure(Throwable t) {
        for (ConfigurationListener<T> listener : listeners) {
            try {
                listener.updateFailed(t);
            } catch (Exception e) {
                logger.error("Updating a listener with configuration request failure failed.", e);
            }
        }
    }
881103
protected Object handleResult(Result result) throws ActivityException {
        ServiceValuesAccess serviceValues = getRuntimeContext().getServiceValues();
        StatusResponse statusResponse;
        if (result.isError()) {
            logsevere("Validation error: " + result.getStatus().toString());
            statusResponse = new StatusResponse(result.getWorstCode(), result.getStatus().getMessage());
            String responseHeadersVarName = serviceValues.getResponseHeadersVariableName();
            Map<String,String> responseHeaders = serviceValues.getResponseHeaders();
            if (responseHeaders == null) {
                Variable responseHeadersVar = getMainProcessDefinition().getVariable(responseHeadersVarName);
                if (responseHeadersVar == null)
                    throw new ActivityException("Missing response headers variable: " + responseHeadersVarName);
                responseHeaders = new HashMap<>();
            }
            responseHeaders.put(Listener.METAINFO_HTTP_STATUS_CODE, String.valueOf(statusResponse.getStatus().getCode()));
            setVariableValue(responseHeadersVarName, responseHeaders);
        }
        else {
            statusResponse = new StatusResponse(com.centurylink.mdw.model.Status.OK, "Valid request");
        }
        String responseVariableName = serviceValues.getResponseVariableName();
        Variable responseVariable = getMainProcessDefinition().getVariable(responseVariableName);
        if (responseVariable == null)
            throw new ActivityException("Missing response variable: " + responseVariableName);
        Object responseObject;
        if (responseVariable.getType().equals(Jsonable.class.getName()))
            responseObject = statusResponse; // _type has not been set, so serialization would fail
        else
            responseObject = serviceValues.fromJson(responseVariableName, statusResponse.getJson());
        setVariableValue(responseVariableName, responseObject);
        return !result.isError();
    }
586134
public void requestCompleted (T result)
    {
        _result = result;
        ResultListener<T> list = _list;
        _list = null;

        list.requestCompleted(result);
    }
369204
public RetryerBuilder<V> withRetryListener(@Nonnull RetryListener listener) {
        Preconditions.checkNotNull(listener, "listener may not be null");
        listeners.add(listener);
        return this;
    }