<commit_before>#ifndef FSM11_DETAIL_MULTITHREADING_HPP
#define FSM11_DETAIL_MULTITHREADING_HPP

#include "statemachine_fwd.hpp"

#include <mutex>
#include <type_traits>

namespace fsm11
{
namespace detail
{

class NoMultithreading
{
public:
    template <typename T = void>
    void lock()
    {
        static_assert(!std::is_same<T, T>::value,
                      "Multithreading support is not enabled");
    }

    template <typename T = void>
    void unlock()
    {
        static_assert(!std::is_same<T, T>::value,
                      "Multithreading support is not enabled");
    }

protected:
    inline
    int getLock() const
    {
        return 0;
    }
};

class Multithreading
{
public:
    void lock()
    {
        m_mutex.lock();
    }

    void unlock()
    {
        m_mutex.unlock();
    }

protected:
    mutable std::recursive_mutex m_mutex;

    inline
    std::unique_lock<std::recursive_mutex> getLock() const
    {
        return std::unique_lock<std::recursive_mutex>(m_mutex);
    }
};

template <bool TEnabled>
struct get_multithreading_helper
{
    typedef NoMultithreading type;
};

template <>
struct get_multithreading_helper<true>
{
    typedef Multithreading type;
};

template <typename TOptions>
struct get_multithreading : public get_multithreading_helper<TOptions::multithreading_enable><commit_msg>Harmonize policy class names.<commit_after>#ifndef FSM11_DETAIL_MULTITHREADING_HPP
#define FSM11_DETAIL_MULTITHREADING_HPP

#include "statemachine_fwd.hpp"

#include <mutex>
#include <type_traits>

namespace fsm11
{
namespace detail
{

class WithoutMultithreading
{
public:
    template <typename T = void>
    void lock()
    {
        static_assert(!std::is_same<T, T>::value,
                      "Multithreading support is not enabled");
    }

    template <typename T = void>
    void unlock()
    {
        static_assert(!std::is_same<T, T>::value,
                      "Multithreading support is not enabled");
    }

protected:
    inline
    int getLock() const
    {
        return 0;
    }
};

class WithMultithreading
{
public:
    void lock()
    {
        m_mutex.lock();
    }

    void unlock()
    {
        m_mutex.unlock();
    }

protected:
    mutable std::recursive_mutex m_mutex;

    inline
    std::unique_lock<std::recursive_mutex> getLock() const
    {
        return std::unique_lock<std::recursive_mutex>(m_mutex);
    }
};

template <bool TEnabled>
struct get_multithreading_helper
{
    typedef WithoutMultithreading type;
};

template <>
struct get_multithreading_helper<true>
{
    typedef WithMultithreading type;
};

template <typename TOptions>
struct get_multithreading : public get_multithreading_helper<TOptions::multithreading_enable>
{'fraction_non_alphanumeric': 0.09816176470588235, 'fraction_numerical': 0.005147058823529412, 'mean_word_length': 3.1797235023041477, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7358664', 'n_tokens_mistral': 924, 'n_tokens_neox': 861, 'n_words': 182}