起线程回调各个接口，避免其中一个回调者耗时长影响其他调用者
@param rstCode 结果码
@param callback 回调
439848
private void aSysnCallback(final int rstCode, final IClientConnectCallback callback) {
        ThreadUtil.INST.excute(new Runnable() {
            @Override
            public void run() {
                HuaweiApiClient client =  getApiClient();
                HMSAgentLog.d("callback connect: rst=" + rstCode + " apiClient=" + client);
                callback.onConnect(rstCode, client);
            }
        });
    }
187471
@Override
    public void executeEventCallback(Runnable callback) {
        if (!nodeEngine.isRunning()) {
            return;
        }
        try {
            eventExecutor.execute(callback);
        } catch (RejectedExecutionException e) {
            rejectedCount.inc();

            if (eventExecutor.isLive()) {
                logFailure("EventQueue overloaded! Failed to execute event callback: %s", callback);
            }
        }
    }
850286
void readAttributeAndPush(EventChannelStruct eventChannelStruct, EventCallBackStruct callbackStruct) {
        //	Check if known event name
        boolean found = false;
        for (int i = 0; !found && i < eventNames.length; i++)
            found = callbackStruct.event_name.equals(eventNames[i]);
        if (!found)
            return;

        //	Else do the synchronous call
        DeviceAttribute deviceAttribute = null;
        DevicePipe      devicePipe = null;
        AttributeInfoEx info = null;
        DeviceInterface deviceInterface = null;
        DevError[] err = null;
        String domain_name = callbackStruct.device.name() + "/" + callbackStruct.attr_name;
        boolean old_transp = callbackStruct.device.get_transparency_reconnection();
        callbackStruct.device.set_transparency_reconnection(true);
        try {
            callbackStruct.setSynchronousDone(false);
            if (callbackStruct.event_name.equals(eventNames[ATT_CONF_EVENT])) {
                info = callbackStruct.device.get_attribute_info_ex(callbackStruct.attr_name);
            }
            else
            if (callbackStruct.event_name.equals(eventNames[PIPE_EVENT])) {
                devicePipe = callbackStruct.device.readPipe(callbackStruct.attr_name);
            }
            else
            if (callbackStruct.event_name.equals(eventNames[INTERFACE_CHANGE])) {
                deviceInterface = new DeviceInterface(callbackStruct.device);
            }
            else {
                deviceAttribute = callbackStruct.device.read_attribute(callbackStruct.attr_name);
            }
            callbackStruct.setSynchronousDone(true);

            // The reconnection worked fine. The heartbeat should come back now,
            // when the notifd has not closed the connection.
            // Increase the counter to detect when the heartbeat is not coming back.
            eventChannelStruct.has_notifd_closed_the_connection++;
        } catch (DevFailed e) {
            err = e.errors;
        }
        callbackStruct.device.set_transparency_reconnection(old_transp);

        //  Build event data and push it.
        //  ToDo DevIntrChange
        EventData eventData =
                new EventData(callbackStruct.device,
                        domain_name,
                        callbackStruct.event_name,
                        callbackStruct.event_type,
                        getSource(eventChannelStruct.consumer),
                        deviceAttribute, devicePipe,
                        info, null, deviceInterface, err);

        if (callbackStruct.use_ev_queue) {
            EventQueue ev_queue = callbackStruct.device.getEventQueue();
            ev_queue.insert_event(eventData);
        } else {
            callbackStruct.callback.push_event(eventData);
        }
    }
788995
private String parseCT_Rst(XMLEventReader xmlEventReader) throws XMLStreamException {
    // Precondition: pointing to <si>;  Post condition: pointing to </si>
    StringBuilder buf = new StringBuilder();
    XMLEvent xmlEvent;
    while((xmlEvent = xmlEventReader.nextTag()).isStartElement()) {
      switch(xmlEvent.asStartElement().getName().getLocalPart()) {
        case "t": // Text
          buf.append(xmlEventReader.getElementText());
          break;
        case "r": // Rich Text Run
          parseCT_RElt(xmlEventReader, buf);
          break;
        case "rPh": // Phonetic Run
        case "phoneticPr": // Phonetic Properties
          skipElement(xmlEventReader);
          break;
        default:
          throw new IllegalArgumentException(xmlEvent.asStartElement().getName().getLocalPart());
      }
    }
    return buf.length() > 0 ? buf.toString() : null;
  }
724024
@Override
    public <R, T extends Object> R callMethod(final String methodName, final T argument, final long timeout) throws CouldNotPerformException, InterruptedException {

        final String shortArgument = RPCHelper.argumentToString(argument);
        validateMiddleware();
        long retryTimeout = METHOD_CALL_START_TIMEOUT;
        long validTimeout = timeout;

        try {
            logger.debug("Calling method [" + methodName + "(" + shortArgument + ")] on scope: " + remoteServer.getScope().toString());
            if (!isConnected()) {
                waitForConnectionState(CONNECTED, timeout);
            }

            if (timeout > -1) {
                retryTimeout = Math.min(METHOD_CALL_START_TIMEOUT, validTimeout);
            }

            while (true) {

                if (!isActive()) {
                    throw new InvalidStateException("Remote service is not active!");
                }

                try {
                    logger.debug("Calling method [" + methodName + "(" + shortArgument + ")] on scope: " + remoteServer.getScope().toString());
                    remoteServerWatchDog.waitForServiceActivation(timeout, TimeUnit.MILLISECONDS);
                    final R returnValue = remoteServer.call(methodName, argument, retryTimeout);

                    if (retryTimeout != METHOD_CALL_START_TIMEOUT && retryTimeout > 15000) {
                        logger.info("Method[" + methodName + "(" + shortArgument + ")] returned! Continue processing...");
                    }
                    return returnValue;

                } catch (TimeoutException ex) {

                    // check if timeout is set and handle
                    if (timeout != -1) {
                        validTimeout -= retryTimeout;
                        if (validTimeout <= 0) {
                            ExceptionPrinter.printHistory(ex, logger, LogLevel.WARN);
                            throw new TimeoutException("Could not call remote Method[" + methodName + "(" + shortArgument + ")] on Scope[" + remoteServer.getScope() + "] in Time[" + timeout + "ms].");
                        }
                        retryTimeout = Math.min(generateTimeout(retryTimeout), validTimeout);
                    } else {
                        retryTimeout = generateTimeout(retryTimeout);
                    }

                    // only print warning if timeout is too long.
                    if (retryTimeout > 15000) {
                        ExceptionPrinter.printHistory(ex, logger, LogLevel.WARN);
                        logger.warn("Waiting for RPCServer[" + remoteServer.getScope() + "] to call method [" + methodName + "(" + shortArgument + ")]. Next retry timeout in " + (int) (Math.floor(retryTimeout / 1000)) + " sec.");
                    } else {
                        ExceptionPrinter.printHistory(ex, logger, LogLevel.DEBUG);
                        logger.debug("Waiting for RPCServer[" + remoteServer.getScope() + "] to call method [" + methodName + "(" + shortArgument + ")]. Next retry timeout in " + (int) (Math.floor(retryTimeout / 1000)) + " sec.");
                    }

                    Thread.yield();
                }
            }
        } catch (TimeoutException ex) {
            throw ex;
        } catch (CouldNotPerformException ex) {
            throw new CouldNotPerformException("Could not call remote Method[" + methodName + "(" + shortArgument + ")] on Scope[" + remoteServer.getScope() + "].", ex);
        }
    }
642076
function jsGetCallback(node, cb) {
        return function(e) {
            e = e || global.event;
            
            if(e.type === 'load' || regJSLOAD.test(node.readyState)) {
                
                //确保执行一次+内存回收
                node.onload = node.onerror = node.onreadystatechange = null

                if(node.parentNode && !config.debug) {
                    HEAD.removeChild(node)
                }
            
                node = undefined

                cb()
            }
        }

    }
988497
public void registerCallback(UOWScopeCallback callback)
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "registerCallback", new Object[]{callback, this});
        
        _callbackManager.addCallback(callback);
        
        if (tc.isEntryEnabled()) Tr.exit(tc, "registerCallback");
    }
854329
public void send(String data, EventCallback callback) {
        send(data, null, null, callback);
    }
943731
function (callbackError, callbackResult, otherArgs) {
        // forbid to call twice
        if (syncCallback.called) return;
        syncCallback.called = true;
        
        if (callbackError) {
            err = callbackError;
        }
        else if (otherArgs) {
            // Support multiple callback result values
            result = [];
            for (var i = 1, l = arguments.length; i < l; i++) {
                result.push(arguments[i]);
            }
        }
        else {
            result = callbackResult;
        }
        
        // Resume fiber if yielding
        if (yielded) fiber.run();
    }
570202
public synchronized <T extends Response> long request(Request<T> request, RpcCallback<T> callback, long timeout) {
        if (request == null) {
            throw new RuntimeException("Request can't be null");
        }
        long rid = NEXT_RPC_ID.incrementAndGet();
        this.apiBroker.send(new ApiBroker.PerformRequest(rid, request, callback, timeout));
        return rid;
    }
1267670
@Override
    public void onConnect(int rst, HuaweiApiClient client) {
        if (isCurFloatShow && client != null) {
            showFinal(true, null, client);
        }
    }
112992
function (callback) {
            async.map([ "tid.dat.gz", "tid_pos.dat.gz", "tid_map.dat.gz" ], function (filename, _callback) {
                loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
                    if(err) {
                        return _callback(err);
                    }
                    _callback(null, buffer);
                });
            }, function (err, buffers) {
                if(err) {
                    return callback(err);
                }
                var token_info_buffer = new Uint8Array(buffers[0]);
                var pos_buffer = new Uint8Array(buffers[1]);
                var target_map_buffer = new Uint8Array(buffers[2]);

                dic.loadTokenInfoDictionaries(token_info_buffer, pos_buffer, target_map_buffer);
                callback(null);
            });
        }
1118660
@Override
    @FFDCIgnore(IOException.class)
    public void complete(VirtualConnection vc, TCPReadRequestContext rsc) {

        if(vc == null){
            return;
        }
        synchronized(_srtUpgradeStream){
            if(_upgradeStream.isClosing()){
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "The upgradedStream is closing, won't notify user of data");
                }
                _srtUpgradeStream.notify();
                return;
            }

            //We have read our 1 byte of data. Now configure the buffer for use when the user calls read
            _upgradeStream.configurePostInitialReadBuffer();
        }
        try{
            //Set the original Context Class Loader before calling the users onDataAvailable
            //Push the original thread's context onto the current thread, also save off the current thread's context
            _contextManager.pushContextData();

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Calling user's ReadListener.onDataAvailable : " + _rl);
            }
            //Call into the user's ReadListener to indicate there is data available
            _rl.onDataAvailable();

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "User's ReadListener.onDataAvailable complete, reading for more data : " + _rl);
            }
        } catch(Throwable onDataAvailableException) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "ReadListener.onDataAvailable threw an exception : " + onDataAvailableException + ", " + _rl);
            }
            //Call directly into the customers ReadListener.onError
            _rl.onError(onDataAvailableException);
        } finally {
            //Revert back to the thread's current context
            _contextManager.popContextData();

            synchronized(_srtUpgradeStream){
                if(!_upgradeStream.isClosing()){
                    _upgradeStream.initialRead();
                } else {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "The upgradedStream is closing, won't issue the initial read");
                    }
                    _srtUpgradeStream.notify();
                }
            }
        }
    }
330148
protected void invokeCallbacks(ThreadLocalRandom r) {
        final Set<SelectionKey> selectedKeys = m_selector.selectedKeys();
        final int keyCount = selectedKeys.size();
        int startInx = r.nextInt(keyCount);
        int itInx = 0;
        Iterator<SelectionKey> it = selectedKeys.iterator();
        while(itInx < startInx) {
            it.next();
            itInx++;
        }
        while(itInx < keyCount) {
            final Object obj = it.next().attachment();
            if (obj == null) {
                continue;
            }
            final VoltPort port = (VoltPort)obj;
            callPort(port);
            itInx++;
        }
        itInx = 0;
        it = selectedKeys.iterator();
        while(itInx < startInx) {
            final Object obj = it.next().attachment();
            if (obj == null) {
                continue;
            }
            final VoltPort port = (VoltPort)obj;
            callPort(port);
            itInx++;
        }
        selectedKeys.clear();
    }
32294
function updateNode(node, callback) {
  syncDb.update(node._id, node, (err, result) => {
    if(err) return callback(err);

    callback(null, node);
  });
}
693306
private void pushServerNotRespondingException(EventChannelStruct eventChannelStruct, EventCallBackStruct callbackStruct) {
        try {
            if (eventChannelStruct != null) {
                if (eventChannelStruct.consumer instanceof NotifdEventConsumer) {
                    if (!callbackStruct.filter_ok) {
                        callbackStruct.filter_id = NotifdEventConsumer.getInstance().add_filter_for_channel(
                                eventChannelStruct, callbackStruct.filter_constraint);
                        callbackStruct.filter_ok = true;
                    }
                }
            } else
                return;

            CallBack callback = callbackStruct.callback;
            DevError[] errors = {new DevError()};
            errors[0].severity = ErrSeverity.ERR;
            errors[0].origin = "EventConsumer.KeepAliveThread";
            errors[0].reason = "API_EventTimeout";
            errors[0].desc = "Event channel is not responding any more, maybe the server or event system is down";
            String domain_name = callbackStruct.device.name() + "/" + callbackStruct.attr_name.toLowerCase();
            EventData event_data =
                    new EventData(eventChannelStruct.adm_device_proxy,
                            domain_name, callbackStruct.event_name, EventData.NOTIFD_EVENT,
                            callbackStruct.event_type, null, null, null, null, null, errors);

            event_data.device = callbackStruct.device;
            event_data.name = callbackStruct.device.name();
            event_data.event = callbackStruct.event_name;

            if (callbackStruct.use_ev_queue) {
                EventQueue ev_queue = callbackStruct.device.getEventQueue();
                ev_queue.insert_event(event_data);
            } else
                callback.push_event(event_data);
        } catch (DevFailed e) { /* */ }
    }
974936
public void completeCallback(final Callback callback, final String error, final JsonNode result) {
        ObjectNode req = makeRequest("complete");
        req.put("cbid", callback.getCbid());
        req.put("err", error);
        req.set("result", result);

        this.runtime.requestResponse(req);
    }