<commit_before>#include "ThreadHandler.hpp"

//<<constructor>>
ThreadHandler::ThreadHandler() {}

//<<destructor>>
ThreadHandler::~ThreadHandler() {}

// get the list of queued animation threads
std::vector<AnimationThread*> ThreadHandler::listAnimationThreads() { return anim_threads; }

// get the list of queued process threads
std::vector<ProcessThread*> ThreadHandler::listProcessThreads() { return proc_threads; }

// queue an animation
void ThreadHandler::queue(Animation* anim) {
	anim->init();

	// dequeue conflicting threads
	dequeueConflicts(anim);

	// queue this animation as a new thread (set current time as the update rate so it initially sets on start)
	AnimationThread* t = new AnimationThread(next_id, anim);
	next_id++;

	anim_threads.push_back(t);

	Serial.print(F("ThreadHandler.cpp:> New Animation Thread Queued: "));
	Serial.print(anim->getName());
	Serial.print(F(" at "));
	Serial.print(anim->getUpdateRate());
	Serial.print(F(" mHz"));
	Serial.print(F(", occupying "));
	Serial.print(mem_available - freeMemory());
	Serial.println(F(" bytes of SRAM"));

	mem_available = freeMemory();
}

// queue a process
void ThreadHandler::queue(Process* proc) {
	proc->init();

	// queue this process as a new thread (set current time as the update rate so it initially sets on start)
	ProcessThread* t = new ProcessThread(next_id, proc);
	next_id++;

	proc_threads.push_back(t);

	Serial.print(F("ThreadHandler.cpp:> New Process Thread Queued: "));
	Serial.print(proc->getName());
	Serial.print(F(" at "));
	Serial.print(proc->getUpdateRate());
	Serial.print(F(" mHz"));
	Serial.print(F(", occupying "));
	Serial.print(mem_available - freeMemory());
	Serial.println(F(" bytes of SRAM"));

	mem_available = freeMemory();
}

// update the time sums for each thread
void ThreadHandler::updateTimeAccumulated(unsigned long int dT) {
	// iterate through each queued animation thread
	for (std::vector<AnimationThread*>::iterator it = anim_threads.begin(); it != anim_threads.end(); it++) {
		(*it)->addTimeSum(dT);;<commit_msg>fixed memory display<commit_after>#include "ThreadHandler.hpp"

//<<constructor>>
ThreadHandler::ThreadHandler() {}

//<<destructor>>
ThreadHandler::~ThreadHandler() {}

// get the list of queued animation threads
std::vector<AnimationThread*> ThreadHandler::listAnimationThreads() { return anim_threads; }

// get the list of queued process threads
std::vector<ProcessThread*> ThreadHandler::listProcessThreads() { return proc_threads; }

// queue an animation
void ThreadHandler::queue(Animation* anim) {
	anim->init();

	// queue this animation as a new thread (set current time as the update rate so it initially sets on start)
	AnimationThread* t = new AnimationThread(next_id, anim);
	next_id++;

	Serial.print(F("ThreadHandler.cpp:> New Animation Thread Generated: "));
	Serial.print(anim->getName());
	Serial.print(F(" at "));
	Serial.print(anim->getUpdateRate());
	Serial.print(F(" mHz"));
	Serial.print(F(", occupying "));
	Serial.print(mem_available - freeMemory());
	Serial.println(F(" bytes of SRAM"));
	Serial.println(anim->getNumStrips());

	//dequeue conflicting threads
	dequeueConflicts(anim); // this MUST be after memory calculations

	anim_threads.push_back(t);

	Serial.println(F("ThreadHandler.cpp:> Animation Thread Queued."));

	mem_available = freeMemory();
}

// queue a process
void ThreadHandler::queue(Process* proc) {
	proc->init();

	// queue this process as a new thread (set current time as the update rate so it initially sets on start)
	ProcessThread* t = new ProcessThread(next_id, proc);
	next_id++;

	proc_threads.push_back(t);

	Serial.print(F("ThreadHandler.cpp:> New Process Thread Queued: "));
	Serial.print(proc->getName());
	Serial.print(F(" at "));
	Serial.print(proc->getUpdateRate());
	Serial.print(F(" mHz"));
	Serial.print(F(", occupying "));
	Serial.print(mem_available - freeMemory());
	Serial.println(F(" bytes of SRAM"));

	mem_available = freeMemory();
}

// update the time sums for each thread
void ThreadHandler::updateTimeAccumulated(unsigned long int dT) {
	// iterate through each queued animation thread
	for (std::vector<AnimationThread*>::iterator it = anim_threads.begin(); it != anim_threads.end(); it++) {
		(*it)->addTimeSum(dT);;
{'fraction_non_alphanumeric': 0.15246636771300448, 'fraction_numerical': 0.0, 'mean_word_length': 5.663522012578617, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 37, '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': '1510520', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1263, 'n_words': 348}