Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Oct 8, 2023
1 parent 18b5fa1 commit 86f7622
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rxlib/src/main/java/org/rx/core/EventBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Map<Class<?>, Set<Tuple<Object, Method>>> findAllSubscribers(Object listener) {
Map<Class<?>, Set<Tuple<Object, Method>>> methodsInListener = new HashMap<>();
for (Method method : Linq.from(Reflects.getMethodMap(listener instanceof Class ? (Class<?>) listener : listener.getClass()).values()).selectMany(p -> p).where(p -> p.isAnnotationPresent(Subscribe.class) && !p.isSynthetic())) {
if (method.getParameterCount() != 1) {
throw new InvalidException("Subscriber method %s has @Subscribe annotation must have exactly 1 parameter.", method);
throw new InvalidException("Subscriber method {} has @Subscribe annotation must have exactly 1 parameter.", method);
}
Class<?> eventType = method.getParameterTypes()[0];
methodsInListener.computeIfAbsent(eventType, k -> new HashSet<>()).add(Tuple.of(listener, method));
Expand Down
9 changes: 9 additions & 0 deletions rxlib/src/main/java/org/rx/core/FluentWait.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static <T> FluentWait polling(long timeoutMillis, long intervalMillis, Bi
private BiFunc<FluentWait, Object> resultFunc;
private List<Class<? extends Throwable>> ignoredExceptions;
private String message;
private boolean initialDelay;
private long retryMillis = TIMEOUT_INFINITE;
private BiAction<FluentWait> retryFunc;
private boolean retryOnStart;
Expand All @@ -63,6 +64,11 @@ public synchronized FluentWait withMessage(String message) {
return this;
}

public synchronized FluentWait withInitialDelay() {
this.initialDelay = true;
return this;
}

public FluentWait retryEvery(long interval, BiAction<FluentWait> retryFunc) {
return retryEvery(interval, retryFunc, false);
}
Expand Down Expand Up @@ -135,6 +141,9 @@ public synchronized <T> T await(@NonNull BiFunc<FluentWait, T> resultFunc) throw
boolean doRetry = retryCount > TIMEOUT_INFINITE;
Throwable cause;
T result = null;
if (initialDelay) {
sleep(interval);
}
do {
try {
if ((result = resultFunc.invoke(this)) != null) {
Expand Down

0 comments on commit 86f7622

Please sign in to comment.