class MessageDispatcher implements Consumer<M>, Disposable {

  @Override
  public void accept(final M message) {
    if (disposed) {
      return;
    }

    runner.post(
        () -> {
          try {
            consumer.accept(message);
          } catch (Throwable throwable) {
            MobiusHooks.handleError(
                new RuntimeException(
                    "Consumer threw an exception when accepting message: " + message, throwable));
          }
        });
  }

    MessageDispatcher(WorkRunner runner, Consumer<M> consumer);

}