package com.straice.smoothdoors.util;

public final class SyncGuard {
    private static final ThreadLocal<Boolean> IN = ThreadLocal.withInitial(() -> false);

    private SyncGuard() {}

    public static boolean isIn() { return IN.get(); }

    public static void run(Runnable r) {
        if (isIn()) return;
        IN.set(true);
        try { r.run(); }
        finally { IN.set(false); }
    }
}
