<commit_before>#define _GNU_SOURCE
#include "timers.h"
#include <stdio.h>
#include <time.h>
#include <stdbool.h>
#include <unistd.h>
#include "uvbloop.h"


#define MAXEVENTS 64


void *timer_loop(void *ptr) {
    uvbloop_event_t *events;
    if((events = calloc(MAXEVENTS, sizeof(uvbloop_event_t))) == NULL) {
        perror("calloc");
        return NULL;
    }
    timer_mgr_t *p = (timer_mgr_t *)ptr;
    int waiting;
    timer_entry_t *entry = NULL;
    while(true) {
        waiting = uvbloop_wait(p->loop, events, MAXEVENTS);
        if(waiting > 0) {
            for(int i=0; i<waiting; i++) {
                entry = (timer_entry_t *)uvbloop_event_data(events);
                uvbloop_reset_timer(p->loop, entry->id);
                if(entry->func(entry->data) < 0) {
                    perror("timer()");
                }
            }
        }

    }
}


int timer_mgr_init(timer_mgr_t *t) {
    pthread_mutex_init(&t->mutex, NULL);<commit_msg>fixed bug where the timers uvbloop events were not being treated as an array<commit_after>#define _GNU_SOURCE
#include "timers.h"
#include <stdio.h>
#include <time.h>
#include <stdbool.h>
#include <unistd.h>
#include "uvbloop.h"


#define MAXEVENTS 64


void *timer_loop(void *ptr) {
    uvbloop_event_t *events;
    if((events = calloc(MAXEVENTS, sizeof(uvbloop_event_t))) == NULL) {
        perror("calloc");
        return NULL;
    }
    timer_mgr_t *p = (timer_mgr_t *)ptr;
    int waiting;
    timer_entry_t *entry = NULL;
    while(true) {
        waiting = uvbloop_wait(p->loop, events, MAXEVENTS);
        if(waiting > 0) {
            for(int i=0; i<waiting; i++) {
                entry = (timer_entry_t *)uvbloop_event_data(&events[i]);
                uvbloop_reset_timer(p->loop, entry->id);
                if(entry->func(entry->data) < 0) {
                    perror("timer()");
                }
            }
        }

    }
}


int timer_mgr_init(timer_mgr_t *t) {
    pthread_mutex_init(&t->mutex, NULL);
{'fraction_non_alphanumeric': 0.14055415617128464, 'fraction_numerical': 0.005037783375314861, 'mean_word_length': 2.4006849315068495, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, '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': '3771770', 'n_tokens_mistral': 739, 'n_tokens_neox': 718, 'n_words': 136}