Skip to content

Commit

Permalink
Format the code
Browse files Browse the repository at this point in the history
  • Loading branch information
r-gurzkowski committed Nov 29, 2024
1 parent 5e6b84b commit 7f814ee
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 42 deletions.
2 changes: 0 additions & 2 deletions mobius-core/src/main/java/com/spotify/mobius/Mobius.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import com.spotify.mobius.internal_util.ImmutableUtil;
import com.spotify.mobius.runners.WorkRunner;
import com.spotify.mobius.runners.WorkRunners;

import java.util.Set;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

Expand Down
73 changes: 35 additions & 38 deletions mobius-core/src/main/java/com/spotify/mobius/MobiusPlugins.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,47 @@

import com.spotify.mobius.runners.WorkRunner;
import com.spotify.mobius.runners.WorkRunners;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class MobiusPlugins {

@Nullable
private static WorkRunner EFFECT_RUNNER_OVERRIDE;
@Nullable
private static WorkRunner EVENT_RUNNER_OVERRIDE;

/**
* Sets the effect runner that will be used in {@link MobiusLoop} when effectRunner was not
* provided to {@link MobiusLoop.Builder}.
*
* @param defaultEffectRunner the {@link WorkRunner} to use as the default effect runner
*/
public static void setDefaultEffectRunner(WorkRunner defaultEffectRunner) {
EFFECT_RUNNER_OVERRIDE = defaultEffectRunner;
}

/**
* Sets the event runner that will be used in {@link MobiusLoop} when eventRunner was not
* provided to {@link MobiusLoop.Builder}.
*
* @param defaultEventRunner the {@link WorkRunner} to use as the default event runner
*/
public static void setDefaultEventRunner(WorkRunner defaultEventRunner) {
EVENT_RUNNER_OVERRIDE = defaultEventRunner;
}

@Nonnull
static WorkRunner defaultEffectRunner() {
if (EFFECT_RUNNER_OVERRIDE != null) {
return EFFECT_RUNNER_OVERRIDE;
}
return WorkRunners.cachedThreadPool();
@Nullable private static WorkRunner EFFECT_RUNNER_OVERRIDE;
@Nullable private static WorkRunner EVENT_RUNNER_OVERRIDE;

/**
* Sets the effect runner that will be used in {@link MobiusLoop} when effectRunner was not
* provided to {@link MobiusLoop.Builder}.
*
* @param defaultEffectRunner the {@link WorkRunner} to use as the default effect runner
*/
public static void setDefaultEffectRunner(WorkRunner defaultEffectRunner) {
EFFECT_RUNNER_OVERRIDE = defaultEffectRunner;
}

/**
* Sets the event runner that will be used in {@link MobiusLoop} when eventRunner was not provided
* to {@link MobiusLoop.Builder}.
*
* @param defaultEventRunner the {@link WorkRunner} to use as the default event runner
*/
public static void setDefaultEventRunner(WorkRunner defaultEventRunner) {
EVENT_RUNNER_OVERRIDE = defaultEventRunner;
}

@Nonnull
static WorkRunner defaultEffectRunner() {
if (EFFECT_RUNNER_OVERRIDE != null) {
return EFFECT_RUNNER_OVERRIDE;
}
return WorkRunners.cachedThreadPool();
}

@Nonnull
static WorkRunner defaultEventRunner() {
if (EVENT_RUNNER_OVERRIDE != null) {
return EVENT_RUNNER_OVERRIDE;
}
return WorkRunners.singleThread();
@Nonnull
static WorkRunner defaultEventRunner() {
if (EVENT_RUNNER_OVERRIDE != null) {
return EVENT_RUNNER_OVERRIDE;
}
return WorkRunners.singleThread();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;

import javax.annotation.Nonnull;

/**
Expand Down Expand Up @@ -72,7 +71,7 @@ public Thread newThread(Runnable runnable) {
Thread thread = Executors.defaultThreadFactory().newThread(checkNotNull(runnable));

thread.setName(
String.format(Locale.ENGLISH, "mobius-thread-%d", threadCount.incrementAndGet()));
String.format(Locale.ENGLISH, "mobius-thread-%d", threadCount.incrementAndGet()));

return thread;
}
Expand Down

0 comments on commit 7f814ee

Please sign in to comment.