<commit_before>// Copyright (C) 2016 <NAME>
// This file is part of the Ouzel engine.

#include <algorithm>
#include "EventDispatcher.h"

namespace ouzel
{
    EventDispatcher::EventDispatcher()
    {

    }

    EventDispatcher::~EventDispatcher()
    {

    }

    void EventDispatcher::update()
    {
        auto eventHandlersCopy = eventHandlers;

        while (!eventQueue.empty())
        {
            mutex.lock();

            Event event = eventQueue.front();
            eventQueue.pop();

            mutex.unlock();

            bool propagate = true;

            for (const EventHandlerPtr& eventHandler : eventHandlersCopy)
            {
                if (eventHandler)
                {
                    switch (event.type)
                    {
                        case Event::Type::KEY_DOWN:
                        case Event::Type::KEY_UP:<commit_msg>Move queue empty check to the critical section<commit_after>// Copyright (C) 2016 <NAME>
// This file is part of the Ouzel engine.

#include <algorithm>
#include "EventDispatcher.h"

namespace ouzel
{
    EventDispatcher::EventDispatcher()
    {

    }

    EventDispatcher::~EventDispatcher()
    {

    }

    void EventDispatcher::update()
    {
        auto eventHandlersCopy = eventHandlers;
        Event event;

        while (true)
        {
            // scope for mutex lock
            {
                std::lock_guard<std::mutex> mutexLock(mutex);
                if (eventQueue.empty())
                {
                    break;
                }

                event = eventQueue.front();
                eventQueue.pop();
            }

            bool propagate = true;

            for (const EventHandlerPtr& eventHandler : eventHandlersCopy)
            {
                if (eventHandler)
                {
                    switch (event.type)
                    {
                        case Event::Type::KEY_DOWN:
                        case Event::Type::KEY_UP:
{'fraction_non_alphanumeric': 0.09389197375063099, 'fraction_numerical': 0.004038364462392731, 'mean_word_length': 1.3995157384987893, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '7199041', 'n_tokens_mistral': 538, 'n_tokens_neox': 481, 'n_words': 114}