<commit_before>package org.axonframework.axonserver.connector.heartbeat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicReference;

import static java.util.concurrent.TimeUnit.MILLISECONDS;

/**
 * Responsible to scheduler at fixed rate a generic task.
 * The scheduling can be started an stopped at any time.
 *
 * @author <NAME>
 * @since 4.2.1
 */
public class Scheduler {

    private static final Logger LOGGER = LoggerFactory.getLogger(Scheduler.class);

    private static final long DEFAULT_INITIAL_DELAY = 10_000;

    private static final long DEFAULT_RATE = 1_000;

    private final ScheduledExecutorService scheduler;

    private final long initialDelay;

    private final long rate;

    private final AtomicReference<ScheduledFuture> scheduledTask = new AtomicReference<>();

    private final Runnable runnable;

    /**
     * Constructs an instance of a {@link Scheduler} using a default initial delay of 10 seconds,
     * a default scheduling period of 1 second and a single thread {@link ScheduledExecutorService}.
     *
     * @param runnable the task to be scheduled
     */
    public Scheduler(Runnable runnable) {
        this(runnable, Executors.newSingleThreadScheduledExecutor());<commit_msg>Implemented high level heartbeat in order to detect disconnection from server as soon as possible. Documentation improvement.<commit_after>package org.axonframework.axonserver.connector.heartbeat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicReference;

import static java.util.concurrent.TimeUnit.MILLISECONDS;

/**
 * Responsible to schedule generic tasks at a fixed rate.
 * The scheduling can be started an stopped at any time.
 *
 * @author <NAME>
 * @since 4.2.1
 */
public class Scheduler {

    private static final Logger LOGGER = LoggerFactory.getLogger(Scheduler.class);

    private static final long DEFAULT_INITIAL_DELAY = 10_000;

    private static final long DEFAULT_RATE = 1_000;

    private final ScheduledExecutorService scheduler;

    private final long initialDelay;

    private final long rate;

    private final AtomicReference<ScheduledFuture> scheduledTask = new AtomicReference<>();

    private final Runnable runnable;

    /**
     * Constructs an instance of a {@link Scheduler} using a default initial delay of 10 seconds,
     * a default scheduling period of 1 second and a single thread {@link ScheduledExecutorService}.
     *
     * @param runnable the task to be scheduled
     */
    public Scheduler(Runnable runnable) {
        this(runnable, Executors.newSingleThreadScheduledExecutor());
{'fraction_non_alphanumeric': 0.07205982324949015, 'fraction_numerical': 0.011556764106050306, 'mean_word_length': 4.264758497316637, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7326250', 'n_tokens_mistral': 831, 'n_tokens_neox': 773, 'n_words': 261}