<commit_before>//
// $Id: IntervalManager.java,v 1.7 2002/05/24 21:32:29 mdb Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 <NAME>
// 
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.samskivert.util;

import java.util.Timer;
import java.util.TimerTask;

import com.samskivert.Log;

/**
 * Can be used to register an object that is to be called once or
 * repeatedly after an interval has expired. This now uses {@link Timer}
 * to do all the actual scheduling, but we keep this front end because it
 * is static (accessible anywhere), provides a single thread where
 * disparate simple intervals can all run happily, and because {@link
 * Interval} is an interface, unlike {@link TimerTask}, which is an
 * abstract class.
 */
public class IntervalManager
{
    /**
     * Schedule the intervaled object to get called after an interval.
     *
     * @param i the intervaled object
     * @param timout # of ms until interval is up.
     * @param arg object to be passed when interval expires
     * @param recur if true, interval gets called every timeout until
     *              removed.
     *
     * @return an ID number that will passed to the {@link
     * Interval#intervalExpired} method of i along with arg
     */
    public static int register (Interval i, long delay, Object arg,
				boolean recur)
    {
        IntervalTask task = new IntervalTask(i, arg, recur);
        _hash.put(task.id, task);

        if (recur) {
            _timer.scheduleAtFixedRate(task, delay, delay);
        } else {
            _timer.schedule(task, delay);<commit_msg>Updated javadoc.<commit_after>//
// $Id: IntervalManager.java,v 1.8 2002/08/09 23:33:38 shaper Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 <NAME>
// 
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.samskivert.util;

import java.util.Timer;
import java.util.TimerTask;

import com.samskivert.Log;

/**
 * Can be used to register an object that is to be called once or
 * repeatedly after an interval has expired. This now uses {@link Timer}
 * to do all the actual scheduling, but we keep this front end because it
 * is static (accessible anywhere), provides a single thread where
 * disparate simple intervals can all run happily, and because {@link
 * Interval} is an interface, unlike {@link TimerTask}, which is an
 * abstract class.
 */
public class IntervalManager
{
    /**
     * Schedules the intervaled object to get called after an interval.
     *
     * @param i the intervaled object
     * @param delay the milliseconds until the interval expires.
     * @param arg the object to be passed to the interval when the
     * interval delay expires.
     * @param recur if true, interval gets called every timeout until
     * removed.
     *
     * @return an ID number that will passed to the {@link
     * Interval#intervalExpired} method of i along with arg
     */
    public static int register (
        Interval i, long delay, Object arg, boolean recur)
    {
        IntervalTask task = new IntervalTask(i, arg, recur);
        _hash.put(task.id, task);

        if (recur) {
            _timer.scheduleAtFixedRate(task, delay, delay);
        } else {
            _timer.schedule(task, delay);
{'fraction_non_alphanumeric': 0.07888531618435156, 'fraction_numerical': 0.015434083601286173, 'mean_word_length': 3.0189491817398793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '376293', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1209, 'n_words': 614}