Skip to content

Commit

Permalink
Get rid of useless running sheduler while connection is closed.
Browse files Browse the repository at this point in the history
Signed-off-by: David Joos <david.joos@bosch-si.com>
  • Loading branch information
David Joos committed Jul 9, 2019
1 parent 73fa954 commit c417795
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -648,7 +648,7 @@ private void openConnection(final OpenConnection command) {
final PerformTask performTask = new PerformTask("open connection",
subscribeForEventsAndScheduleResponse(commandResponse, origin));
self.tell(performTask, ActorRef.noSender());
this.checkLoggingEnabled();
this.startEnabledLoggingChecker(Duration.ofMillis(1));
},
error -> handleException("open-connection", origin, error)
);
Expand Down Expand Up @@ -685,6 +685,7 @@ private void closeConnection(final CloseConnection command) {
origin.tell(closeConnectionResponse, getSelf());
});
self.tell(performTask, ActorRef.noSender());
this.cancelEnabledLoggingChecker();
},
error -> handleException("disconnect", origin, error),
() -> {
Expand Down Expand Up @@ -763,10 +764,11 @@ private void cancelEnabledLoggingChecker() {
}
}

private void startEnabledLoggingChecker() {
private void startEnabledLoggingChecker(Duration... initialDelay) {
this.cancelEnabledLoggingChecker();
final Duration delay = initialDelay.length >= 1 ? initialDelay[0] : this.checkLoggingActiveInterval;
this.enabledLoggingChecker = getContext().getSystem().scheduler().schedule(
this.checkLoggingActiveInterval,
delay,
this.checkLoggingActiveInterval,
getSelf(),
CheckLoggingActive.INSTANCE,
Expand Down

0 comments on commit c417795

Please sign in to comment.