Skip to content

Commit

Permalink
Use enum for no-op PauseDetectorWrapper #2474
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Aug 7, 2023
1 parent 92f462c commit 69c6fa2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,41 +357,45 @@ public void shutdown() {
}

/**
* Wrapper for initialization of {@link PauseDetector}. Encapsulates absence of LatencyUtils.
* No-op implementation of {@link PauseDetectorWrapper}.
*/
interface PauseDetectorWrapper {
enum NoOpPauseDetectorWrapper implements PauseDetectorWrapper {

/**
* No-operation {@link PauseDetectorWrapper} implementation.
*/
PauseDetectorWrapper NO_OP = new PauseDetectorWrapper() {
INSTANCE;

@Override
public void release() {
}
@Override
public void retain() {

@Override
public void retain() {
}
}

@Override
public Object getPauseDetector() {
return NoPauseDetector.INSTANCE;
}
@Override
public void release() {

};
}

@Override
public Object getPauseDetector() {
return NoPauseDetector.INSTANCE;
}

}

/**
* Wrapper for initialization of {@link PauseDetector}. Encapsulates absence of LatencyUtils.
*/
interface PauseDetectorWrapper {

static PauseDetectorWrapper create() {

if (HDR_UTILS_AVAILABLE && LATENCY_UTILS_AVAILABLE) {
return new DefaultPauseDetectorWrapper();
}

return NO_OP;
return NoOpPauseDetectorWrapper.INSTANCE;
}

static PauseDetectorWrapper noop() {
return NO_OP;
return NoOpPauseDetectorWrapper.INSTANCE;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Args=--initialize-at-build-time=io.lettuce.core.metrics.DefaultCommandLatencyCollector,io.lettuce.core.internal.LettuceClassUtils
Args=--initialize-at-build-time=io.lettuce.core.metrics.DefaultCommandLatencyCollector,io.lettuce.core.metrics.DefaultCommandLatencyCollector$NoOpPauseDetectorWrapper,io.lettuce.core.internal.LettuceClassUtils

0 comments on commit 69c6fa2

Please sign in to comment.