<commit_before>
#include "unitig_manager.h"

#include "unitig_walker.h"

#include <core/patterns/manager.h>

struct thorium_script bsal_unitig_manager_script = {
    .identifier = SCRIPT_UNITIG_MANAGER,
    .name = "bsal_unitig_manager",
    .init = bsal_unitig_manager_init,
    .destroy = bsal_unitig_manager_destroy,
    .receive = bsal_unitig_manager_receive,
    .size = sizeof(struct bsal_unitig_manager),
    .description = "Testbed for testing ideas."
};

void bsal_unitig_manager_init(struct thorium_actor *self)
{
    struct bsal_unitig_manager *concrete_self;
    concrete_self = (struct bsal_unitig_manager *)thorium_actor_concrete_actor(self);

    bsal_vector_init(&concrete_self->spawners, sizeof(int));
    bsal_vector_init(&concrete_self->walkers, sizeof(int));
    bsal_vector_init(&concrete_self->graph_stores, sizeof(int));

    concrete_self->completed = 0;
    concrete_self->manager = THORIUM_ACTOR_NOBODY;
}

void bsal_unitig_manager_destroy(struct thorium_actor *self)
{
    struct bsal_unitig_manager *concrete_self;
    concrete_self = (struct bsal_unitig_manager *)thorium_actor_concrete_actor(self);

    bsal_vector_destroy(&concrete_self->spawners);
    bsal_vector_destroy(&concrete_self->walkers);
    bsal_vector_destroy(&concrete_self->graph_stores);

    concrete_self->completed = 0;
    concrete_self->manager = THORIUM_ACTOR_NOBODY;
}

/*
 * Basically, this actor does this:
 * - spawn walkers
 * - let them walk
 * - kill the walkers
 * - return OK
 */
void bsal_unitig_manager_receive(struct thorium_actor *self, struct thorium_message *message)
{
    struct bsal_unitig_manager *concrete_self;
    int tag;
    void *buffer;
    int spawner;

    tag = thorium_message_tag(message);
    buffer = thorium_message_buffer(message);

    concrete_self = (struct bsal_unitig_manager *)thorium_actor_concrete_actor(self);

    if (tag == ACTION_START) {

        bsal_vector_unpack(&concrete_self->spawners, buffer);

        spawner = thorium_actor_get_random_spawner(self, &concrete_self->spawners);

        thorium_actor_send_int(self, spawner, ACTION_SPAWN, SCRIPT_MANAGER);

    } else if (tag == ACTION_SPAWN_REPLY) {

        thorium_message_unpack_int(message, 0, &concrete_self->manager);

        thorium_actor_send_int(self, concrete_self->manager, ACTION_MANAGER_SET_SCRIPT,
                        SCRIPT_UNITIG_WALKER);

    } else if (tag == ACTION_ASK_TO_STOP) {

        thorium_actor_send_to_self_empty(self, ACTION_STOP);

        thorium_actor_send_empty(self, concrete_self->manager,
                        ACTION_ASK_TO_STOP);

        thorium_actor_send_reply_empty(self, ACTION_ASK_TO_STOP_REPLY);

    } else if (tag == ACTION_MANAGER_SET_SCRIPT_REPLY) {

        thorium_actor_send_reply_vector(self, ACTION_START,<commit_msg>increase number of walker to 4<commit_after>
#include "unitig_manager.h"

#include "unitig_walker.h"

#include <core/patterns/manager.h>

#define UNITIG_WALKER_COUNT_PER_WORKER 4

struct thorium_script bsal_unitig_manager_script = {
    .identifier = SCRIPT_UNITIG_MANAGER,
    .name = "bsal_unitig_manager",
    .init = bsal_unitig_manager_init,
    .destroy = bsal_unitig_manager_destroy,
    .receive = bsal_unitig_manager_receive,
    .size = sizeof(struct bsal_unitig_manager),
    .description = "The chief executive for unitig walkers"
};

void bsal_unitig_manager_init(struct thorium_actor *self)
{
    struct bsal_unitig_manager *concrete_self;
    concrete_self = (struct bsal_unitig_manager *)thorium_actor_concrete_actor(self);

    bsal_vector_init(&concrete_self->spawners, sizeof(int));
    bsal_vector_init(&concrete_self->walkers, sizeof(int));
    bsal_vector_init(&concrete_self->graph_stores, sizeof(int));

    concrete_self->completed = 0;
    concrete_self->manager = THORIUM_ACTOR_NOBODY;
}

void bsal_unitig_manager_destroy(struct thorium_actor *self)
{
    struct bsal_unitig_manager *concrete_self;
    concrete_self = (struct bsal_unitig_manager *)thorium_actor_concrete_actor(self);

    bsal_vector_destroy(&concrete_self->spawners);
    bsal_vector_destroy(&concrete_self->walkers);
    bsal_vector_destroy(&concrete_self->graph_stores);

    concrete_self->completed = 0;
    concrete_self->manager = THORIUM_ACTOR_NOBODY;
}

/*
 * Basically, this actor does this:
 * - spawn walkers
 * - let them walk
 * - kill the walkers
 * - return OK
 */
void bsal_unitig_manager_receive(struct thorium_actor *self, struct thorium_message *message)
{
    struct bsal_unitig_manager *concrete_self;
    int tag;
    void *buffer;
    int spawner;

    tag = thorium_message_tag(message);
    buffer = thorium_message_buffer(message);

    concrete_self = (struct bsal_unitig_manager *)thorium_actor_concrete_actor(self);

    if (tag == ACTION_START) {

        bsal_vector_unpack(&concrete_self->spawners, buffer);

        spawner = thorium_actor_get_random_spawner(self, &concrete_self->spawners);

        thorium_actor_send_int(self, spawner, ACTION_SPAWN, SCRIPT_MANAGER);

    } else if (tag == ACTION_SPAWN_REPLY) {

        thorium_message_unpack_int(message, 0, &concrete_self->manager);

        thorium_actor_send_int(self, concrete_self->manager, ACTION_MANAGER_SET_SCRIPT,
                        SCRIPT_UNITIG_WALKER);

    } else if (tag == ACTION_ASK_TO_STOP) {

        thorium_actor_send_to_self_empty(self, ACTION_STOP);

        thorium_actor_send_empty(self, concrete_self->manager,
                        ACTION_ASK_TO_STOP);

        thorium_actor_send_reply_empty(self, ACTION_ASK_TO_STOP_REPLY);

    } else if (tag == ACTION_MANAGER_SET_SCRIPT_REPLY) {

        thorium_actor_send_reply_int(self, ACTION_MANAGER_SET_ACTORS_PER_WORKER,
                        UNITIG_WALKER_COUNT_PER_WORKER);

    } else if (tag == ACTION_MANAGER_SET_ACTORS_PER_WORKER_REPLY) {

        thorium_actor_send_reply_vector(self, ACTION_START,
{'fraction_non_alphanumeric': 0.08960573476702509, 'fraction_numerical': 0.00136542072025943, 'mean_word_length': 4.481758652946679, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '2545513', 'n_tokens_mistral': 2135, 'n_tokens_neox': 2027, 'n_words': 308}