<commit_before>#include "Singleton.h"

namespace commonOptions {

auto Singleton::getInstance() -> Singleton& {
	static Singleton instance;
	return instance;
}


auto Singleton::register_on_before_save(std::function<void()> _callback) -> CallbackHandler {
	std::unique_lock<std::mutex> lock(mMutex);

	id += 1;
	mCallbacksOnBeforeSave.emplace_back(std::make_pair(id, _callback));
	return CallbackHandler { new CallbackOnExitHandler ([=] {
		std::unique_lock<std::mutex> lock(mMutex);
		for (auto iter = mCallbacksOnBeforeSave.begin(); iter != mCallbacksOnBeforeSave.end(); ++iter) {
			if (iter->first == id) {
				mCallbacksOnBeforeSave.erase(iter);
				return;
			}
		}
	}) };
}

auto Singleton::register_on_save(std::function<void()> _callback) -> CallbackHandler {
	std::unique_lock<std::mutex> lock(mMutex);

	id += 1;
	mCallbacksOnSave.emplace_back(std::make_pair(id, _callback));
	return CallbackHandler { new CallbackOnExitHandler ([=] {
		std::unique_lock<std::mutex> lock(mMutex);
		for (auto iter = mCallbacksOnSave.begin(); iter != mCallbacksOnSave.end(); ++iter) {
			if (iter->first == id) {
				mCallbacksOnSave.erase(iter);
				return;
			}
		}
	}) };
}
auto Singleton::register_on_load(std::function<void()> _callback) -> CallbackHandler {
	std::unique_lock<std::mutex> lock(mMutex);

	mCallbacksOnLoad.emplace_back(std::make_pair(id, _callback));
	return CallbackHandler { new CallbackOnExitHandler ([=] {
		std::unique_lock<std::mutex> lock(mMutex);
		for (auto iter = mCallbacksOnLoad.begin(); iter != mCallbacksOnLoad.end(); ++iter) {
			if (iter->first == id) {
				mCallbacksOnLoad.erase(iter);
				return;
			}
		}
	}) };<commit_msg>adding missing id increment for on_load register<commit_after>#include "Singleton.h"

namespace commonOptions {

auto Singleton::getInstance() -> Singleton& {
	static Singleton instance;
	return instance;
}


auto Singleton::register_on_before_save(std::function<void()> _callback) -> CallbackHandler {
	std::unique_lock<std::mutex> lock(mMutex);

	id += 1;

	auto copyID = id;
	mCallbacksOnBeforeSave.emplace_back(std::make_pair(id, _callback));
	return CallbackHandler { new CallbackOnExitHandler ([=] {
		std::unique_lock<std::mutex> lock(mMutex);
		for (auto iter = mCallbacksOnBeforeSave.begin(); iter != mCallbacksOnBeforeSave.end(); ++iter) {
			if (iter->first == copyID) {
				mCallbacksOnBeforeSave.erase(iter);
				return;
			}
		}
	}) };
}

auto Singleton::register_on_save(std::function<void()> _callback) -> CallbackHandler {
	std::unique_lock<std::mutex> lock(mMutex);

	id += 1;

	auto copyID = id;
	mCallbacksOnSave.emplace_back(std::make_pair(id, _callback));
	return CallbackHandler { new CallbackOnExitHandler ([=] {
		std::unique_lock<std::mutex> lock(mMutex);
		for (auto iter = mCallbacksOnSave.begin(); iter != mCallbacksOnSave.end(); ++iter) {
			if (iter->first == copyID) {
				mCallbacksOnSave.erase(iter);
				return;
			}
		}
	}) };
}
auto Singleton::register_on_load(std::function<void()> _callback) -> CallbackHandler {
	std::unique_lock<std::mutex> lock(mMutex);

	id += 1;

	auto copyID = id;
	mCallbacksOnLoad.emplace_back(std::make_pair(id, _callback));
	return CallbackHandler { new CallbackOnExitHandler ([=] {
		std::unique_lock<std::mutex> lock(mMutex);
		for (auto iter = mCallbacksOnLoad.begin(); iter != mCallbacksOnLoad.end(); ++iter) {
			if (iter->first == copyID) {
				mCallbacksOnLoad.erase(iter);
				return;
			}
		}
	}) };
{'fraction_non_alphanumeric': 0.15826289711454386, 'fraction_numerical': 0.001457301078402798, 'mean_word_length': 5.562141491395794, 'pattern_counts': {'":': 0, '<': 21, '<?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': '6936865', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1207, 'n_words': 205}