<commit_before>#include "includes/ThreadedTimerEvent_private.h"

/*******Private Functions*******/
/* Main loop for the thread. */
static void timer_loop(ThreadedTimerEvent* event)
{
	if(!event)return;

	char rang;
	struct timespec end_time;

	flag_raise(&event->fp, THREAD_IS_RUNNING);
	while(!(event->fp & THREAD_STOP))
	{
		TimerEvent_check((TimerEvent*)event, &rang);

		/* Let anyone waiting know that we have rung. */
		if(rang)
			pthread_cond_broadcast(&event->cond);

		if(pthread_mutex_lock(&event->mutex))
				flag_raise(&event->fp, THREAD_STOP);
		end_time = Timer_get_end_time_real_time(event->timer);
		pthread_cond_timedwait(&event->cond, &event->mutex,
				&end_time);

		pthread_mutex_unlock(&event->mutex);
	}
	flag_lower(&event->fp, THREAD_IS_RUNNING);

	pthread_cond_broadcast(&event->cond);
	pthread_cond_broadcast(&event->cond);
}
/*******************************/<commit_msg>Added feature so that ThreadedTimerEvent can be restarted inside the callback function.<commit_after>#include "includes/ThreadedTimerEvent_private.h"

/*******Private Functions*******/
/* Main loop for the thread. */
static void timer_loop(ThreadedTimerEvent* event)
{
	if(!event)return;

	struct timespec end_time;

	flag_raise(&event->fp, THREAD_IS_RUNNING);
	while(!(event->fp & THREAD_STOP))
	{
		TimerEvent_check((TimerEvent*)event, NULL);

		/* Let anyone waiting know that we have rung. */
		if(Timer_get_rung_state(event->timer))
			pthread_cond_broadcast(&event->cond);

		if(pthread_mutex_lock(&event->mutex))
				flag_raise(&event->fp, THREAD_STOP);
		end_time = Timer_get_end_time_real_time(event->timer);
		pthread_cond_timedwait(&event->cond, &event->mutex,
				&end_time);

		pthread_mutex_unlock(&event->mutex);
	}
	flag_lower(&event->fp, THREAD_IS_RUNNING);

	pthread_cond_broadcast(&event->cond);
	pthread_cond_broadcast(&event->cond);
}
/*******************************/
{'fraction_non_alphanumeric': 0.17965023847376788, 'fraction_numerical': 0.0, 'mean_word_length': 6.289575289575289, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, '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': '7528873', 'n_tokens_mistral': 689, 'n_tokens_neox': 644, 'n_words': 105}