eclipse-vertx / eclipse-vertx/vert.x

Probably dispatch method should be reused inside emit

Open
#6,086 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
14.7k
Forks
2.1k
Avg merge
2d 7h
Merged PRs (30d)
28

Description

### Describe the feature

Currently **emit** method looks like
```
@Override
public final void emit(T argument, Handler task) {
if (executor().inThread()) {
ContextInternal prev = beginDispatch();
try {
task.handle(argument);
} catch (Throwable t) {
reportException(t);
} finally {
endDispatch(prev);
}
} else {
executor().execute(() -> emit(argument, task));
}
}
```

while dispatch is
```
default void dispatch(E event, Handler handler) {
ContextInternal prev = beginDispatch();
try {
handler.handle(event);
} catch (Throwable t) {
reportException(t);
} finally {
endDispatch(prev);
}
}

```

so it is effective duplicate logic of **dispatch** in the _"if (executor().inThread())"_ branch.

### Contribution

here is PR https://github.com/eclipse-vertx/vert.x/pull/6085

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.