Performs the provided onTerminate action on the FX thread
@param onTerminate
@param <T>
187519
public static <T> FlowableTransformer<T,T> doOnTerminateFx(Action onTerminate) {
        return obs -> obs.doOnTerminate(() -> runOnFx(onTerminate));
    }
466217
protected void executeExecutionListeners(HasExecutionListeners elementWithExecutionListeners,
      ExecutionEntity executionEntity, String eventType) {
    commandContext.getProcessEngineConfiguration().getListenerNotificationHelper()
      .executeExecutionListeners(elementWithExecutionListeners, executionEntity, eventType);
  }
240297
public void onStartWithServer(ExecutionContext<I> context, ExecutionInfo info) {
        for (ExecutionListener<I, O> listener: listeners) {
            try {
                if (!isListenerDisabled(listener)) {
                    listener.onStartWithServer(context.getChildContext(listener), info);
                }
            } catch (Throwable e) {
                if (e instanceof AbortExecutionException) {
                    throw (AbortExecutionException) e;
                }
                logger.error("Error invoking listener " + listener, e);
            }
        }
    }
330788
protected void fireActionPerformed(ActionEvent event) {
    Object[] listeners = listenerList.getListenerList();
    for(int i = listeners.length - 2; i >= 0; i -= 2) {
      if(listeners[i] == ActionListener.class) {
        ((ActionListener) listeners[i + 1]).actionPerformed(event);
      }
    }
  }
1154782
void runAndWait(Runnable action) {
        if (action == null)
            throw new NullPointerException("action");

        // run synchronously on JavaFX thread
        if (Platform.isFxApplicationThread()) {
            action.run();
            return;
        }

        // queue on JavaFX thread and wait for completion
        final CountDownLatch doneLatch = new CountDownLatch(1);
        Platform.runLater(() -> {
            try {
                action.run();
            } finally {
                doneLatch.countDown();
            }
        });

        try {
            doneLatch.await();
        } catch (InterruptedException e) {
            // ignore exception
        }
    }
1183557
private void processXEvent(X.XEvent event,
                               RunnableProcessor runnableProcessor) {
        switch (X.XEvent.getType(event.p)) {
            case X.ButtonPress: {
                X.XButtonEvent buttonEvent = new X.XButtonEvent(event);
                int button = X.XButtonEvent.getButton(buttonEvent.p);
                runnableProcessor.invokeLater(new ButtonPressProcessor(button));
                break;
            }
            case X.ButtonRelease: {
                X.XButtonEvent buttonEvent = new X.XButtonEvent(event);
                int button = X.XButtonEvent.getButton(buttonEvent.p);
                runnableProcessor.invokeLater(
                        new ButtonReleaseProcessor(button));
                break;
            }
            case X.MotionNotify: {
                X.XMotionEvent motionEvent = new X.XMotionEvent(event);
                int x = X.XMotionEvent.getX(motionEvent.p);
                int y = X.XMotionEvent.getY(motionEvent.p);
                runnableProcessor.invokeLater(new MotionProcessor(x, y));
                break;
            }
        }
    }
780633
function(fromSegment, toSegment) {
			if (fromSegment.reachable && toSegment.reachable) {
				this.emitter.emit(
					"onCodePathSegmentLoop",
					fromSegment,
					toSegment,
					this.currentNode
				);
			}
		}
1310845
@Override
  @SuppressWarnings("checkstyle:diamondoperatorforvariabledefinition")
  public synchronized void onNext(final RemoteEvent<byte[]> value) {

    LOG.log(Level.FINER, "RemoteManager: {0} value: {1}", new Object[] {this.name, value});

    final T decodedEvent = this.codec.decode(value.getEvent());
    final Class<? extends T> clazz = (Class<? extends T>) decodedEvent.getClass();

    LOG.log(Level.FINEST, "RemoteManager: {0} decoded event {1} :: {2}",
        new Object[] {this.name, clazz.getCanonicalName(), decodedEvent});

    // check remote identifier and message type
    final SocketRemoteIdentifier id = new SocketRemoteIdentifier((InetSocketAddress)value.remoteAddress());

    final Tuple2<RemoteIdentifier, Class<? extends T>> tuple =
        new Tuple2<RemoteIdentifier, Class<? extends T>>(id, clazz);

    final EventHandler<? super T> tupleHandler = this.tupleToHandlerMap.get(tuple);

    if (tupleHandler != null) {

      LOG.log(Level.FINER, "Tuple handler: {0},{1}",
          new Object[] {tuple.getT1(), tuple.getT2().getCanonicalName()});

      tupleHandler.onNext(decodedEvent);

    } else {

      final EventHandler<RemoteMessage<? extends T>> messageHandler = this.msgTypeToHandlerMap.get(clazz);

      if (messageHandler == null) {
        final RuntimeException ex = new RemoteRuntimeException(
            "Unknown message type in dispatch: " + clazz.getCanonicalName() + " from " + id);
        LOG.log(Level.WARNING, "Unknown message type in dispatch.", ex);
        throw ex;
      }

      LOG.log(Level.FINER, "Message handler: {0}", clazz.getCanonicalName());

      messageHandler.onNext(new DefaultRemoteMessage<>(id, decodedEvent));
    }
  }
825181
protected void fireChange(boolean force) {

        String value = getFormValueAsString();
        if (force || !value.equals(m_previousValue)) {
            m_previousValue = value;
            ValueChangeEvent.fire(this, value);
        }
    }
117379
@UiThread
  @SafeVarargs public static <T extends View> void run(@NonNull T[] array,
      @NonNull Action<? super T>... actions) {
    for (int i = 0, count = array.length; i < count; i++) {
      for (Action<? super T> action : actions) {
        action.apply(array[i], i);
      }
    }
  }
283345
public void onText (@Nonnull final char [] aText, @Nonnegative final int nOfs, @Nonnegative final int nLen)
  {
    onText (aText, nOfs, nLen, true);
  }
138617
protected void fireAction(ActionListener action) {
        int      modifiers    = 0;
        AWTEvent currentEvent = EventQueue.getCurrentEvent();

        if (currentEvent instanceof InputEvent) {
            modifiers = ((InputEvent) currentEvent).getModifiers();
        } else if (currentEvent instanceof ActionEvent) {
            modifiers = ((ActionEvent) currentEvent).getModifiers();
        }

        ActionEvent e = new ActionEvent(getComponent(), ActionEvent.ACTION_PERFORMED, getComponent().getText(),
                                        EventQueue.getMostRecentEventTime(), modifiers);

        action.actionPerformed(e);
    }
11195
@Override
    public void onFinish(ISuite suite) {
        logger.entering(suite);
        if (ListenerManager.isCurrentMethodSkipped(this)) {
            logger.exiting(ListenerManager.THREAD_EXCLUSION_MSG);
            return;
        }
        LocalGridManager.shutDownHub();
        logger.exiting();
    }
678973
@FXML
    private void send_btn_on_click(ActionEvent event) {
        // Future proof for other uses of send event handler
        if (this.dialogType == DialogType.INPUT_TEXT) {
            this.textEntry = this.inputTextField.getText();
        }

        setResponse(DialogResponse.SEND);
        close();
    }
1096856
public void dispatch_event(final EventData eventData) {
		final TangoPeriodic tangoPeriodic = this;
        if (EventUtil.graphicAvailable()) {
                //   Causes doRun.run() to be executed asynchronously
                //      on the AWT event dispatching thread.
            Runnable do_work_later = new Runnable() {
                public void run() {
                    fireTangoPeriodicEvent(tangoPeriodic, eventData);
                }
            };
            SwingUtilities.invokeLater(do_work_later);
        }
        else
            fireTangoPeriodicEvent(tangoPeriodic, eventData);
    }
1289005
private void cancelOrKillExecution(boolean cancel) {
		final Thread executingThread = this.environment.getExecutingThread();

		if (executingThread == null) {
			return;
		}

		if (this.executionState != ExecutionState.RUNNING && this.executionState != ExecutionState.FINISHING) {
			return;
		}

		LOG.info((cancel ? "Canceling " : "Killing ") + this.environment.getTaskNameWithIndex());

		if (cancel) {
			this.isCanceled = true;
			// Change state
			executionStateChanged(ExecutionState.CANCELING, null);

			// Request user code to shut down
			try {
				final AbstractInvokable invokable = this.environment.getInvokable();
				if (invokable != null) {
					invokable.cancel();
				}
			} catch (Throwable e) {
				LOG.error(StringUtils.stringifyException(e));
			}
		}

		// Continuously interrupt the user thread until it changed to state CANCELED
		while (true) {

			executingThread.interrupt();

			if (!executingThread.isAlive()) {
				break;
			}

			try {
				executingThread.join(1000);
			} catch (InterruptedException e) {}

			if (!executingThread.isAlive()) {
				break;
			}

			if (LOG.isDebugEnabled()) {
				LOG.debug("Sending repeated " + (cancel == true ? "canceling" : "killing") + " signal to " +
						this.environment.getTaskName() + " with state " + this.executionState);
			}
		}
	}
995908
@Trivial
    private void performAction(Runnable action, boolean addToQueue) {
        ExecutorService exec = executorService.getService();

        if (exec == null) {
            // If we can't find the executor service, we have to run it in place.
            action.run();
        } else {
            // If we can find the executor service, we'll add the action to the queue.
            // If the actionFuture is null (no pending actions) and the configFuture is null (no
            // pending configuration updates), we'll submit the actionsRunner to the executor
            // service to drain the queue
            //
            // configFuture is used to avoid bouncing the endpoint multiple times because of a
            // single configuration update.
            //
            // actionFuture is only set to a non-null value by kicking off the executor service here.
            // actionsRunner syncs on actionQueue, so we can't add any new actions while we are
            // draining the queue. When the queue is empty, actionFuture is explicitly set to null.
            //
            // Long story short, it prevents us from kicking off multiple executors which could run in
            // random order.
            if (addToQueue) {
                synchronized (actionQueue) {
                    actionQueue.add(action);
                    if ((actionFuture == null) && (configFuture == null)) {
                        actionFuture = exec.submit(actionsRunner);
                    }
                }
            } else {
                // Schedule immediately
                exec.submit(action);
            }
        }
    }