<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.skree.service.internal.zone.allocator;

import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
import com.skelril.skree.SkreePlugin;
import org.spongepowered.api.scheduler.Task;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.channel.MessageChannel;

import java.util.Optional;

public class RunManager {
    private static ModifiedRunContext supervisor = new ModifiedRunContext();

    public static void runOperation(Operation operation, Runnable callBack) {
        runOperation(operation, callBack, supervisor);
    }

    private static void runOperation(Operation operation, Runnable callBack, ModifiedRunContext context) {
        context.resume();

        Optional<Operation> optNext = Optional.of(operation);
        while (optNext.isPresent() && context.shouldContinue()) {
            try {
                optNext = Optional.ofNullable(optNext.get().resume(context));
            } catch (WorldEditException e) {
                e.printStackTrace();
                return;
            }
        }

        if (optNext.isPresent()) {
            Operation next = optNext.get();
            Task.builder().execute(() -> {
                runOperation(next, callBack, context);
            }).delayTicks(10).submit(SkreePlugin.inst());
        } else {
            callBack.run();
        }
    }

    private static class ModifiedRunContext extends RunContext {
        private long curStart = System.currentTimeMillis();

        public void resume() {
            if (!shouldContinue()) {
                curStart = System.currentTimeMillis();
            }
        }

        @Override
        public boolean shouldContinue() {
            MessageChannel.TO_ALL.send(Text.of("Performing check: ", System.currentTimeMillis() - curStart));
            return System.currentTimeMillis() - curStart < 500;
        }
    }
}
<commit_msg>Removed a debug message for the Run Manager<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.skree.service.internal.zone.allocator;

import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
import com.skelril.skree.SkreePlugin;
import org.spongepowered.api.scheduler.Task;

import java.util.Optional;

public class RunManager {
    private static ModifiedRunContext supervisor = new ModifiedRunContext();

    public static void runOperation(Operation operation, Runnable callBack) {
        runOperation(operation, callBack, supervisor);
    }

    private static void runOperation(Operation operation, Runnable callBack, ModifiedRunContext context) {
        context.resume();

        Optional<Operation> optNext = Optional.of(operation);
        while (optNext.isPresent() && context.shouldContinue()) {
            try {
                optNext = Optional.ofNullable(optNext.get().resume(context));
            } catch (WorldEditException e) {
                e.printStackTrace();
                return;
            }
        }

        if (optNext.isPresent()) {
            Operation next = optNext.get();
            Task.builder().execute(() -> {
                runOperation(next, callBack, context);
            }).delayTicks(10).submit(SkreePlugin.inst());
        } else {
            callBack.run();
        }
    }

    private static class ModifiedRunContext extends RunContext {
        private long curStart = System.currentTimeMillis();

        public void resume() {
            if (!shouldContinue()) {
                curStart = System.currentTimeMillis();
            }
        }

        @Override
        public boolean shouldContinue() {
            return System.currentTimeMillis() - curStart < 500;
        }
    }
}

{'fraction_non_alphanumeric': 0.1022940074906367, 'fraction_numerical': 0.007022471910112359, 'mean_word_length': 2.5197693574958815, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3959772', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1108, 'n_words': 273}