<commit_before>#pragma once // not using standard header-guard in order to not pollute macro completion on GCL_TEST*

#include <iostream>
#include <vector>
#include <list>
#include <cassert>
#include <unordered_map>
#include <functional>
#include <string>
#include <chrono>
#include <thread>
#include <mutex>

#include <gcl_cpp/functionnal.hpp>

namespace gcl
{
	namespace experimental
	{
		namespace test_utils
		{
			namespace Inline
			{
				struct RT_scope_controler final
				{
					using key_type = std::string;
					using mapped_type = bool;
					using value_type = std::pair<const key_type, mapped_type>;
					
					struct Observer
					{
						virtual void	NotifyPropertyChanged(value_type &) = 0;
					};
					using T_ObserversList = std::list<std::shared_ptr<Observer>>;

					using T_Container = std::unordered_map<key_type, mapped_type>;

				private:
					static T_Container		_container;
					static std::mutex		_container_mutex;
					static T_ObserversList	_observers;
					static std::mutex		_obs_mutex;
					static volatile bool	_isActive;
					static void								OnPropertyChanged(value_type & property)
					{
						std::async(std::launch::async, [&property]()
						{
							std::lock_guard<std::mutex> lock(_obs_mutex);
							for (auto & obs : _observers)
								obs->NotifyPropertyChanged(property);
						});
					}

				public:

					static inline volatile bool &			IsActive(void)
					{
						return _isActive;
					}
					static void								AddObserver(std::shared_ptr<Observer> & obs)
					{
						std::lock_guard<std::mutex> lock(_obs_mutex);
						_observers.push_back(obs);
					}
					template <bool default_active_value = false>
					static T_Container::mapped_type			Get(const T_Container::key_type & key)
					{
						std::lock_guard<std::mutex>	lock(_container_mutex);
						T_Container::iterator it = _container.find(key);
						if (it == _container.end())
						{
							auto insert_ret = _container.emplace(value_type(key, default_active_value));
							assert(insert_ret.second);
							OnPropertyChanged(*(insert_ret.first));	// Can be costly
						}
						return _container.at(key);<commit_msg>fix old components (may be deprecated soon, if not refactored) gcl::experimental::test_utils::Inline::RT_scope_controler<commit_after>#pragma once // not using standard header-guard in order to not pollute macro completion on GCL_TEST*

#include <iostream>
#include <vector>
#include <list>
#include <cassert>
#include <unordered_map>
#include <functional>
#include <string>
#include <chrono>
#include <thread>
#include <mutex>

#include <gcl_cpp/functionnal.hpp>

namespace gcl
{
	namespace experimental
	{
		namespace test_utils
		{
			namespace Inline
			{
				struct RT_scope_controler final
				{
					using key_type = std::string;
					using mapped_type = bool;
					using value_type = std::pair<const key_type, mapped_type>;
					
					struct Observer
					{
						virtual void	NotifyPropertyChanged(value_type &) = 0;
					};
					using T_ObserversList = std::list<std::shared_ptr<Observer>>;

					using T_Container = std::unordered_map<key_type, mapped_type>;

				private:
					static T_Container		_container;
					static std::mutex		_container_mutex;
					static T_ObserversList	_observers;
					static std::mutex		_obs_mutex;
					static volatile bool	_isActive;
					static void								OnPropertyChanged(value_type & property)
					{
						auto f = std::async(std::launch::async, [&property]()
						{
							std::lock_guard<std::mutex> lock(_obs_mutex);
							for (auto & obs : _observers)
								obs->NotifyPropertyChanged(property);
						});
						f.wait();
					}

				public:

					static inline volatile bool &			IsActive(void)
					{
						return _isActive;
					}
					static void								AddObserver(std::shared_ptr<Observer> & obs)
					{
						std::lock_guard<std::mutex> lock(_obs_mutex);
						_observers.push_back(obs);
					}
					template <bool default_active_value = false>
					static T_Container::mapped_type			Get(const T_Container::key_type & key)
					{
						std::lock_guard<std::mutex>	lock(_container_mutex);
						T_Container::iterator it = _container.find(key);
						if (it == _container.end())
						{
							auto insert_ret = _container.emplace(value_type(key, default_active_value));
							assert(insert_ret.second);
							OnPropertyChanged(*(insert_ret.first));	// Can be costly
						}
						return _container.at(key);
{'fraction_non_alphanumeric': 0.106218792555606, 'fraction_numerical': 0.00045392646391284613, 'mean_word_length': 3.2786407766990293, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 45, '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': '5545299', 'n_tokens_mistral': 1870, 'n_tokens_neox': 1381, 'n_words': 302}