<commit_before>/* This file is part of the UniSet project
 * Copyright (c) 2002 Free Software Foundation, Inc.
 * Copyright (c) 2002 <NAME>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
// --------------------------------------------------------------------------
/*! \file
 *  \author <NAME>
 *  \date   $Date: 2007/11/29 22:19:54 $
 *  \version $Id: PassiveTimer.cc,v 1.13 2007/11/29 22:19:54 vpashka Exp $
*/
// -------------------------------------------------------------------------- 
#include <time.h>
#include <sys/times.h>
#include <stdio.h>
#include <unistd.h>
#include "PassiveTimer.h"

//----------------------------------------------------------------------------------------
// CLK_TCK    
#ifndef CLK_TCK
#define CLK_TCK sysconf(_SC_CLK_TCK)
#endif
//----------------------------------------------------------------------------------------

//------------------------------------------------------------------------------

PassiveTimer::PassiveTimer( ):
timeAct(0),
timeSS(0),
timeStart(0),
clock_ticks(sysconf(_SC_CLK_TCK))
{
	setTiming(WaitUpTime);
}

//------------------------------------------------------------------------------

PassiveTimer::PassiveTimer( timeout_t timeMS ):
timeAct(0),
timeSS(0),
timeStart(0),
clock_ticks(sysconf(_SC_CLK_TCK))
{
//	printf("const =%d\n",timeMS);
	setTiming( timeMS );
}

//------------------------------------------------------------------------------
bool PassiveTimer::checkTime()
{
//	printf("times=%d, act=%d\n",times(0),timeAct);
//	printf("%d\n",timeSS); msleep(10);

	if( timeSS == WaitUpTime);
		return false;

	if( times() >= timeAct )
		return true;
	return false;
}

//------------------------------------------------------------------------------
//   
timeout_t PassiveTimer::setTiming( timeout_t timeMS )
{
	if( timeMS == WaitUpTime )
	{
		timeSS = WaitUpTime;
	}
	else
	{
		timeSS=timeMS/10; //   
		if (timeMS%10)
			timeSS++; //    
	}
	PassiveTimer::reset();
	return getInterval();
}

//------------------------------------------------------------------------------
//  
void PassiveTimer::reset(void)
{
	timeStart = times();<commit_msg>PassiveTimer: remove extra ;<commit_after>/* This file is part of the UniSet project
 * Copyright (c) 2002 Free Software Foundation, Inc.
 * Copyright (c) 2002 <NAME>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
// --------------------------------------------------------------------------
/*! \file
 *  \author <NAME>
 *  \date   $Date: 2007/11/29 22:19:54 $
 *  \version $Id: PassiveTimer.cc,v 1.13 2007/11/29 22:19:54 vpashka Exp $
*/
// -------------------------------------------------------------------------- 
#include <time.h>
#include <sys/times.h>
#include <stdio.h>
#include <unistd.h>
#include "PassiveTimer.h"

//----------------------------------------------------------------------------------------
// CLK_TCK    
#ifndef CLK_TCK
#define CLK_TCK sysconf(_SC_CLK_TCK)
#endif
//----------------------------------------------------------------------------------------

//------------------------------------------------------------------------------

PassiveTimer::PassiveTimer( ):
timeAct(0),
timeSS(0),
timeStart(0),
clock_ticks(sysconf(_SC_CLK_TCK))
{
	setTiming(WaitUpTime);
}

//------------------------------------------------------------------------------

PassiveTimer::PassiveTimer( timeout_t timeMS ):
timeAct(0),
timeSS(0),
timeStart(0),
clock_ticks(sysconf(_SC_CLK_TCK))
{
//	printf("const =%d\n",timeMS);
	setTiming( timeMS );
}

//------------------------------------------------------------------------------
bool PassiveTimer::checkTime()
{
//	printf("times=%d, act=%d\n",times(0),timeAct);
//	printf("%d\n",timeSS); msleep(10);

	if( timeSS == WaitUpTime)
		return false;

	if( times() >= timeAct )
		return true;
	return false;
}

//------------------------------------------------------------------------------
//   
timeout_t PassiveTimer::setTiming( timeout_t timeMS )
{
	if( timeMS == WaitUpTime )
	{
		timeSS = WaitUpTime;
	}
	else
	{
		timeSS=timeMS/10; //   
		if (timeMS%10)
			timeSS++; //    
	}
	PassiveTimer::reset();
	return getInterval();
}

//------------------------------------------------------------------------------
//  
void PassiveTimer::reset(void)
{
	timeStart = times();
{'fraction_non_alphanumeric': 0.35819027181688123, 'fraction_numerical': 0.02396280400572246, 'mean_word_length': 1.4296264118158124, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '2730567', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1494, 'n_words': 444}