<commit_before>#ifndef MOSQUITTO_CLIENT_H
#define MOSQUITTO_CLIENT_H

typedef struct mosquitto_callback_t mosquitto_callback_t;
typedef struct mosquitto_callback_waiting_t mosquitto_callback_waiting_t;

typedef struct {
    struct mosquitto *mosq;
    VALUE connect_cb;
    VALUE disconnect_cb;
    VALUE publish_cb;
    VALUE message_cb;
    VALUE subscribe_cb;
    VALUE unsubscribe_cb;
    VALUE log_cb;
    VALUE callback_thread;
    pthread_mutex_t callback_mutex;
    pthread_cond_t callback_cond;
    mosquitto_callback_waiting_t *waiter;
    mosquitto_callback_t *callback_queue;
} mosquitto_client_wrapper;

#define MosquittoGetClient(obj) \
    mosquitto_client_wrapper *client = NULL; \
    Data_Get_Struct(obj, mosquitto_client_wrapper, client); \
    if (!client) rb_raise(rb_eTypeError, "uninitialized Mosquitto client!");

#define RetryNotConnectedOnce() \
    if (retried == false) { \
        time.tv_sec  = 0; \
        time.tv_usec = 300 * 1000; \
        rb_thread_wait_for(time); \
        retried = true; \
        goto retry_once; \
    }

#define MosquittoAssertCallback(cb, arity) \
    if (NIL_P(cb)){ \
        cb = proc; \
    } else { \<commit_msg>Reconnect prior to retry<commit_after>#ifndef MOSQUITTO_CLIENT_H
#define MOSQUITTO_CLIENT_H

typedef struct mosquitto_callback_t mosquitto_callback_t;
typedef struct mosquitto_callback_waiting_t mosquitto_callback_waiting_t;

typedef struct {
    struct mosquitto *mosq;
    VALUE connect_cb;
    VALUE disconnect_cb;
    VALUE publish_cb;
    VALUE message_cb;
    VALUE subscribe_cb;
    VALUE unsubscribe_cb;
    VALUE log_cb;
    VALUE callback_thread;
    pthread_mutex_t callback_mutex;
    pthread_cond_t callback_cond;
    mosquitto_callback_waiting_t *waiter;
    mosquitto_callback_t *callback_queue;
} mosquitto_client_wrapper;

#define MosquittoGetClient(obj) \
    mosquitto_client_wrapper *client = NULL; \
    Data_Get_Struct(obj, mosquitto_client_wrapper, client); \
    if (!client) rb_raise(rb_eTypeError, "uninitialized Mosquitto client!");

#define RetryNotConnectedOnce() \
    if (retried == false) { \
        mosquitto_reconnect(client->mosq); \
        time.tv_sec  = 0; \
        time.tv_usec = 300 * 1000; \
        rb_thread_wait_for(time); \
        retried = true; \
        goto retry_once; \
    }

#define MosquittoAssertCallback(cb, arity) \
    if (NIL_P(cb)){ \
        cb = proc; \
    } else { \
{'fraction_non_alphanumeric': 0.08215767634854772, 'fraction_numerical': 0.006639004149377593, 'mean_word_length': 3.5836501901140685, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5358192', 'n_tokens_mistral': 905, 'n_tokens_neox': 830, 'n_words': 162}