If listeners are registered for this event type, run the listeners or
queue the event, if already something is happening for this key.
492228
void deliverAsyncEvent(final EntryEvent<K,V> _event) {
    if (asyncListenerByType.get(_event.getEventType()).isEmpty()) {
      return;
    }
    List<Listener<K,V>> _listeners =
      new ArrayList<Listener<K, V>>(asyncListenerByType.get(_event.getEventType()));
    if (_listeners.isEmpty()) {
      return;
    }
    K key = _event.getKey();
    synchronized (getLockObject(key)) {
      Queue<EntryEvent<K,V>> q = keyQueue.get(key);
      if (q != null) {
        q.add(_event);
        return;
      }
      q = new LinkedList<EntryEvent<K, V>>();
      keyQueue.put(key, q);
    }
    runAllListenersInParallel(_event, _listeners);
  }
160505
public void runMoreOrStop(AsyncEvent<K> _event) {
    for (;;) {
      try {
        _event.execute();
      } catch (Throwable t) {
        cache.getLog().warn("Async event exception", t);
      }
      final K key = _event.getKey();
      synchronized (getLockObject(key)) {
        Queue<AsyncEvent<K>> q = keyQueue.get(key);
        if (q.isEmpty()) {
          keyQueue.remove(key);
          return;
        }
        _event = q.remove();
      }
    }
  }
49479
protected void notifyListeners (int event)
    {
        int size = _listeners.size();
        for (int ii = 0; ii < size; ii++) {
            _listeners.get(ii).modelChanged(event);
        }
    }
108454
def on(self, name, callback, once=False):
        
        if name not in self.event_listeners:
            self.event_listeners[name] = []

        self.event_listeners[name].append((callback, once))
385467
public void registerListenerExtensions() {
    if (listenerExtensionsRegistered) {
      throw H2O.fail("Listeners already registered");
    }

    long before = System.currentTimeMillis();
    ServiceLoader<H2OListenerExtension> extensionsLoader = ServiceLoader.load(H2OListenerExtension.class);
    for (H2OListenerExtension ext : extensionsLoader) {
      ext.init();
      listenerExtensions.put(ext.getName(), ext);
    }
    listenerExtensionsRegistered = true;
    registerListenerExtensionsMillis = System.currentTimeMillis() - before;
  }
866372
public void setListeners(java.util.Collection<Listener> listeners) {
        if (listeners == null) {
            this.listeners = null;
            return;
        }

        this.listeners = new java.util.ArrayList<Listener>(listeners);
    }
245732
function (key) {
    
            key = key.toLowerCase();
        
            var property = this.config[key];
    
            if (property && property.event && 
    
                !Lang.isUndefined(property.value)) {
    
                if (this.queueInProgress) {
    
                    this.queueProperty(key);
    
                } else {
    
                    this.fireEvent(key, property.value);
    
                }
    
            }
        }
496563
public static <L, K> void addListener (Map<K, ListenerList<L>> map, K key, L listener)
    {
        ListenerList<L> list = map.get(key);
        if (list == null) {
            map.put(key, list = new ListenerList<L>());
        }
        list.add(listener);
    }
496725
public void fire(T event) {
		ArrayList<Listener<T>> list1;
		ArrayList<Runnable> list2;
		synchronized (this) {
			if (listeners == null) list1 = null;
			else list1 = new ArrayList<>(listeners);
			if (listenersRunnable == null) list2 = null;
			else list2 = new ArrayList<>(listenersRunnable);
		}
		if (list1 != null)
			for (int i = 0; i < list1.size(); ++i)
				try { list1.get(i).fire(event); }
				catch (Throwable t) {
					LCCore.getApplication().getDefaultLogger().error("Event listener error: " + list1.get(i), t);
				}
		if (list2 != null)
			for (int i = 0; i < list2.size(); ++i)
				try { list2.get(i).run(); }
				catch (Throwable t) {
					LCCore.getApplication().getDefaultLogger().error("Event listener error: " + list2.get(i), t);
				}
	}
327930
protected function listen()
    {
        $events = app('events');
        if (isset($this->listen)) {
            foreach ($this->listen as $event => $listeners) {
                foreach ($listeners as $listener) {
                    $events->listen($event, $listener);
                }
            }
        }
        
        if (isset($this->subscribe)) {
            foreach ($this->subscribe as $subscriber) {
                $events->subscribe($subscriber);
            }
        }
    }
335376
function triggerListeners(listeners, event, args)
  {
    if (listeners && event in listeners)
    {
      var eventListeners = listeners[ event ];
      var triggerGroup = ++triggerId;
      var next, node = eventListeners.next;

      while (node !== eventListeners)
      {
        next = node.next;
        node.trigger( triggerGroup, args, false );
        node = next;
      }

      node = eventListeners.next;

      while (node !== eventListeners)
      {
        next = node.next;
        node.trigger( triggerGroup, args, true );
        node = next;
      }
    }
  }
134349
public synchronized void fire(T event) {
		if (occured) throw new IllegalStateException("SingleEvent already fired");
		occured = true;
		data = event;
		if (listeners != null) {
			for (Listener<T> listener : listeners)
				listener.fire(event);
			listeners = null;
		}
		if (listenersRunnable != null) {
			for (Runnable listener : listenersRunnable)
				listener.run();
			listenersRunnable = null;
		}
	}
925284
def dispatch(self, event):
        

        for event_types, queues in self.queues.items():
            if event.type & event_types:
                for queue in queues:
                    queue.put(event)
467222
public void addlistener(final ChangeListener listener) {
        synchronized (LISTENER_LOCK) {
            if (listeners.contains(listener)) {
                LOGGER.warn("Skip listener registration. listener[" + listener + "] is already registered!");
                return;
            }
            listeners.add(listener);
        }
    }
651520
def _trigger_event(self, event):
    

    if event is None or event not in self.__listeners:
      raise ValueError('invalid event type: {0!r}'.format(event))

    # Check the event has not already been triggered, then mark
    # the event as triggered.
    if event in self.__event_set:
      raise RuntimeError('event already triggered: {0!r}'.format(event))
    self.__event_set.add(event)
    listeners = self.__listeners[event] + self.__listeners[None]

    # Remove one-off listeners.
    self.__listeners[event][:] = (l for l in self.__listeners[event] if not l.once)
    self.__listeners[None][:] = (l for l in self.__listeners[None] if not l.once)

    for listener in listeners:
      # XXX: What to do on exceptions? Catch and make sure all listeners
      # run through? What to do with the exception(s) then?
      listener.callback(self, event)
318476
@Override
	public void run() {
		if (logger.isInfoEnabled()) {
			logger.info(String.format("SelectorThread for Management=%s started.", this.management.getName()));
		}
		while (this.started) {
			try {
				FastList<ChangeRequest> pendingChanges = this.management.getPendingChanges();

				// Process any pending changes
				synchronized (pendingChanges) {
					Iterator<ChangeRequest> changes = pendingChanges.iterator();
					while (changes.hasNext()) {
						ChangeRequest change = changes.next();
						switch (change.getType()) {
						case ChangeRequest.CHANGEOPS:
							pendingChanges.remove(change);
							SelectionKey key = change.getSocketChannel().keyFor(this.selector);
							key.interestOps(change.getOps());
							break;
						case ChangeRequest.REGISTER:
							pendingChanges.remove(change);
							SelectionKey key1 = change.getSocketChannel().register(this.selector, change.getOps());
							key1.attach(change.getAssociation());
							break;
						case ChangeRequest.CONNECT:
							if (!change.getAssociation().isStarted()) {
								// if Association is stopped - remove pending connection requests  
								pendingChanges.remove(change);
							} else {
								if (change.getExecutionTime() <= System.currentTimeMillis()) {
									pendingChanges.remove(change);
									change.getAssociation().initiateConnection();
								}
							}
							break;
						case ChangeRequest.CLOSE:
							pendingChanges.remove(change);
							change.getAssociation().close();
						}
					}// end of while
				}

				// Wait for an event one of the registered channels
				this.selector.select(500);

				// System.out.println("Done selecting " +
				// this.selector.selectedKeys().size());

				// Iterate over the set of keys for which events are available
				Iterator<SelectionKey> selectedKeys = this.selector.selectedKeys().iterator();

				while (selectedKeys.hasNext()) {
					SelectionKey key = selectedKeys.next();
					selectedKeys.remove();

					if (!key.isValid()) {
						continue;
					}

					// Check what event is available and deal with it
					if (key.isConnectable()) {
						this.finishConnection(key);
					} else if (key.isAcceptable()) {
						this.accept(key);
					} else if (key.isReadable()) {
						this.read(key);
					} else if (key.isWritable()) {
						this.write(key);
					}
				}

			} catch (Exception e) {
				logger.error("Error while selecting the ready keys", e);
			}
		}

		try {
			this.selector.close();
		} catch (IOException e) {
			logger.error(String.format("Error while closing Selector for SCTP Management=%s", this.management.getName()));
		}

		if (logger.isInfoEnabled()) {
			logger.info(String.format("SelectorThread for Management=%s stopped.", this.management.getName()));
		}
	}
714094
private void processMethods() {
    Method[] methods = listenerClass.getDeclaredMethods();
    for (Method method : methods) {
      for (CallbackType callbackType : CallbackType.values()) {
        if (method.isAnnotationPresent(callbackType.getAnnotationClass())) {
          validateMethod(method, callbackType);
          metadata.putListener(callbackType, method);
        }
      }
    }
  }