public static void doInEventLoop(EventExecutor eventExecutor, Runnable runnable, Promise<?> promise) {
    try {
      if (eventExecutor.inEventLoop()) {
        runnable.run();
      } else {
        eventExecutor.submit(() -> {
          try {
            runnable.run();
          } catch (Throwable e) {
            promise.setFailure(e);
          }
        });
      }
    } catch (Throwable e) {
      promise.setFailure(e);
    }
  }
Runs a task in the given {@link EventExecutor}. Runs immediately if the current thread is in the
eventExecutor. Notifies the given {@link Promise} if a failure occurs.

@param eventExecutor Executor to run task in.
@param runnable Task to run.
@param promise Promise to notify if failure occurs.
ambry-commons/src/main/java/com/github/ambry/commons/NettyUtils.java