The Deque with the additional events WILL BE MODIFIED by the calling code.

@param event The current event
@return Any additional events that should be injected before the current event. If null the
current event is returned
762374
protected Deque<XMLEvent> getAdditionalEvents(XMLEvent event) {
        final XMLEvent additionalEvent = this.getAdditionalEvent(event);
        if (additionalEvent == null) {
            return null;
        }

        final Deque<XMLEvent> additionalEvents = new LinkedList<XMLEvent>();
        additionalEvents.push(additionalEvent);
        return additionalEvents;
    }
1350660
function(event/*, arg1...*/) {
      var events = this._events[event];

      if (events != null) {
        var args = slice(arguments, 1);
        each(events, function(event) {
          event[2].apply(event[1], args);
        });
      }
      return this;
    }
362209
function (event) {
    if (!event || !_.isObject(event)) {
      var err = new Error('Please inject a valid event object!');
      debug(err);
      throw err;
    }

    if (!event.payload && event.payload !== '') {
      event.payload = this.defaultEventPayload;
    }

    if (this.events.indexOf(event) < 0) {
      this.events.push(event);
    }
  }
252097
public static Optional<JobReturnEvent> parse(Event event) {
        Matcher matcher = PATTERN.matcher(event.getTag());
        if (matcher.matches()) {
            Data data = event.getData(Data.class);
            JobReturnEvent result = new JobReturnEvent(matcher.group(1), matcher.group(2),
                    data);
            return Optional.of(result);
        } else {
            return Optional.empty();
        }
    }
1160602
public void addEvent(E event) {
    CompletableFuture<E> future = futures.poll();
    if (future != null) {
      future.complete(event);
    } else {
      events.add(event);
      if (events.size() > 100) {
        events.remove();
      }
    }
  }
1007693
@Override
    public void dispatch(@Nonnull final NessEvent event)
    {
        if (event == null) {
            LOG.trace("Dropping null event");
        }
        else {

            for (final NessEventReceiver receiver : eventReceivers) {
                try {
                    if (receiver.accept(event)) {
                        receiver.receive(event);
                    }
                } catch (Exception e) {
                    // don't reraise. We prefer to not disrupt event handling by other receievers
                    LOG.error(e, "Exception during event handling by %s of event %s", receiver, event);
                }
            }
        }
    }
1266712
public static Optional<BeaconEvent> parse(Event event) {
        Matcher matcher = PATTERN.matcher(event.getTag());
        if (matcher.matches()) {
            BeaconEvent result = new BeaconEvent(matcher.group(1), matcher.group(2),
                    matcher.group(3), event.getData(JsonElement.class));
            return Optional.of(result);
        } else {
            return Optional.empty();
        }
    }
849065
public <T> Future<T> fireEventAsynchronously(final Event<?> event) {
        final FutureTask<T> futureTask = new FutureTask<T>(() -> {
            synchronizedEventQueue.fireEvent(event);

            return null; // XXX: Our future????
        });

        Latkes.EXECUTOR_SERVICE.execute(futureTask);

        return futureTask;
    }
815161
@Override
    public void add(Event event) {
        if (getNumStoredEvents() >= maxEvents) {
            logger.warn("Not adding Event because at least "
                + Integer.toString(maxEvents) + " events are already stored: " + event.getId());
            return;
        }

        File eventFile = new File(bufferDir.getAbsolutePath(), event.getId().toString() + FILE_SUFFIX);
        if (eventFile.exists()) {
            logger.trace("Not adding Event to offline storage because it already exists: "
                + eventFile.getAbsolutePath());
            return;
        } else {
            logger.debug("Adding Event to offline storage: " + eventFile.getAbsolutePath());
        }

        try (FileOutputStream fileOutputStream = new FileOutputStream(eventFile);
             ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
            objectOutputStream.writeObject(event);
        } catch (Exception e) {
            logger.error("Error writing Event to offline storage: " + event.getId(), e);
        }

        logger.debug(Integer.toString(getNumStoredEvents())
            + " stored events are now in dir: "
            + bufferDir.getAbsolutePath());
    }
17314
public static void post(final Event event) {
        if (!isEnable()) {
            return;
        }
        CopyOnWriteArraySet<Subscriber> subscribers = SUBSCRIBER_MAP.get(event.getClass());
        if (CommonUtils.isNotEmpty(subscribers)) {
            for (final Subscriber subscriber : subscribers) {
                if (subscriber.isSync()) {
                    handleEvent(subscriber, event);
                } else { // 异步
                    final RpcInternalContext context = RpcInternalContext.peekContext();
                    final ThreadPoolExecutor asyncThreadPool = AsyncRuntime.getAsyncThreadPool();
                    try {
                        asyncThreadPool.execute(
                            new Runnable() {
                                @Override
                                public void run() {
                                    try {
                                        RpcInternalContext.setContext(context);
                                        handleEvent(subscriber, event);
                                    } catch (Exception e) {
                                        RpcInternalContext.removeContext();
                                    }
                                }
                            });
                    } catch (RejectedExecutionException e) {
                        LOGGER
                            .warn("This queue is full when post event to async execute, queue size is " +
                                asyncThreadPool.getQueue().size() +
                                ", please optimize this async thread pool of eventbus.");
                    }
                }
            }
        }
    }
1195097
@Transactional
	public List<DeferredEvent> getDeferredEvents() {
		if (log.isDebugEnabled()) {
			Query query = m_entityManager.createNamedQuery("DeferredEventsDebug");
			@SuppressWarnings("unchecked")
			List<DeferredEvent> result = query.getResultList();
			log.debug("#found {} deferred events",result.size());
			for (DeferredEvent deferredEvent:result) {
				log.debug("#deferred event: {} fire: {} now: {} created: {}",deferredEvent.getEventType(), deferredEvent.getFire(),new Date().getTime(),deferredEvent.getCreated());
			}
		}
		long now = new Date().getTime();
		Query query = m_entityManager.createNamedQuery("DeferredEvents").setParameter("rightNow", now);
		@SuppressWarnings("unchecked")
		List<DeferredEvent> result = query.getResultList();
		log.debug("found {} deferred events",result.size());
		return result;
	}
24444
@Beta
    public EventGridEvent[] deserializeEventGridEvents(final String requestContent, final SerializerAdapter<ObjectMapper> serializerAdapter) throws IOException {
        EventGridEvent[] eventGridEvents = serializerAdapter.<EventGridEvent[]>deserialize(requestContent, EventGridEvent[].class);
        for (EventGridEvent receivedEvent : eventGridEvents) {
            if (receivedEvent.data() == null) {
                continue;
            } else {
                final String eventType = receivedEvent.eventType();
                final Type eventDataType;
                if (SystemEventTypeMappings.containsMappingFor(eventType)) {
                    eventDataType = SystemEventTypeMappings.getMapping(eventType);
                } else if (containsCustomEventMappingFor(eventType)) {
                    eventDataType = getCustomEventMapping(eventType);
                } else {
                    eventDataType = null;
                }
                if (eventDataType != null) {
                    final String eventDataAsString = serializerAdapter.serializeRaw(receivedEvent.data());
                    final Object eventData = serializerAdapter.<Object>deserialize(eventDataAsString, eventDataType);
                    setEventData(receivedEvent, eventData);
                }
            }
        }
        return eventGridEvents;
    }
472334
public void offer(Event event) {
        sequence += event.toString();
        
        //check pattern matching
        if (patterns != null && sequence.length() > 0) {
            for (int i = 0; i < patterns.length; i++) {
                if (sequence.matches(patterns[i])) {
                    listener.patternMatches(i, sequence);
                    
                    //nullify sequence;
                    sequence = "";
                    return;
                }
            }
        }
        
        //check the amount of detected event and notify listener
        //if limit reached.
        if (count > 0 && sequence.length() == count) {
            listener.countMatches(sequence);
            sequence = "";
            count = -1;
        }
    }
570497
private void getInertIndex(HashMap event) {
        int iDate;
        try {
            iDate = Integer.parseInt(getValueOr(event, "date", ""));
        } catch (Exception e) {
            next = events.size();
            return;
        }
        for (int i = isEventExist() ? next : 0; i < events.size(); i++) {
            try {
                if (iDate < Integer.parseInt(getValueOr(events.get(i), "date", "0"))) {
                    next = i;
                    return;
                }
            } catch (Exception e) {
            }
        }

        next = events.size();
    }
838680
@Override
  public void onNext(final T event) {
    LOG.log(Level.FINEST, "Invoked for event: {0}", event);
    lock.readLock().lock();
    final List<EventHandler<? extends T>> list;
    try {
      list = clazzToListOfHandlersMap.get(event.getClass());
      if (list == null) {
        throw new WakeRuntimeException("No event " + event.getClass() + " handler");
      }
      for (final EventHandler<? extends T> handler : list) {
        LOG.log(Level.FINEST, "Invoking {0}", handler);
        ((EventHandler<T>) handler).onNext(event);
      }
    } finally {
      lock.readLock().unlock();
    }
  }
675969
protected void dispatchEvent (DEvent event)
    {
//         Log.info("Dispatching event: " + evt);

        // look up the object on which we're dispatching this event
        int remoteOid = event.getTargetOid();
        DObject target = _ocache.get(remoteOid);
        if (target == null) {
            if (!_dead.containsKey(remoteOid)) {
                log.warning("Unable to dispatch event on non-proxied object " + event + ".");
            }
            return;
        }

        // because we might be acting as a proxy for a remote server, we may need to fiddle with
        // this event before we dispatch it
        _client.convertFromRemote(target, event);

        // if this is a compound event, we need to process its contained events in order
        if (event instanceof CompoundEvent) {
            // notify our proxy subscribers in one fell swoop
            target.notifyProxies(event);

            // now break the event up and dispatch each event to listeners individually
            List<DEvent> events = ((CompoundEvent)event).getEvents();
            int ecount = events.size();
            for (int ii = 0; ii < ecount; ii++) {
                dispatchEvent(remoteOid, target, events.get(ii));
            }

        } else {
            // forward to any proxies (or not if we're dispatching part of a compound event)
            target.notifyProxies(event);

            // and dispatch the event to regular listeners
            dispatchEvent(remoteOid, target, event);
        }
    }
1083785
private void getNextEventIndex() {
        for (int i = next + 1; i < events.size(); i++) {
            String evName = getValueOr(events.get(i), "event", "");
            if (evName.equals(eventType)) {
                next = i;
                return;
            }
        }
        next = events.size();
    }