Skip to content
Snippets Groups Projects
Select Git revision
  • Sprint/2021-19
  • master default protected
  • gitkeep
  • dev protected
  • Issue/2449-GuidPidSlugToProjectSettings
  • Issue/2309-docs
  • Issue/2355-topLevelOrg
  • Issue/2328-noFailOnLog
  • Hotfix/2371-fixGitLabinRCV
  • Issue/2287-guestRole
  • Fix/xxxx-activateGitlab
  • Test/xxxx-enablingGitLab
  • Issue/2349-gitlabHttps
  • Issue/2259-updatePids
  • Issue/2101-gitLabResTypeUi
  • Hotfix/2202-fixNaNQuota
  • Issue/2246-quotaResoval
  • Issue/2221-projectDateCreated
  • Hotfix/2224-quotaSizeAnalytics
  • Fix/xxxx-resourceVisibility
  • Issue/2000-gitlabResourcesAPI
  • v4.4.3
  • v4.4.2
  • v4.4.1
  • v4.4.0
  • v4.3.4
  • v4.3.3
  • v4.3.2
  • v4.3.1
  • v4.3.0
  • v4.2.8
  • v4.2.7
  • v4.2.6
  • v4.2.5
  • v4.2.4
  • v4.2.3
  • v4.2.2
  • v4.2.1
  • v4.2.0
  • v4.1.1
  • v4.1.0
41 results

Startup.cs

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    QueueDispatcher.cpp 1.17 KiB
    #include "QueueDispatcher.h"
    
    namespace Utility
    {
    
        QueueDispatcher::QueueDispatcher()
        {
            m_manual = true;
        }
    
    
        QueueDispatcher::~QueueDispatcher()
        {
            // Stop execution
            set_manual();
        }
        void QueueDispatcher::set_manual()
        {
            m_manual = true;
            if (t_execution.joinable())
            {
                t_execution.join();
            }
        }
        bool QueueDispatcher::execute_one()
        {
            if (m_manual)
            {
                if (auto action = m_queue.pop())
                {
                    action.get().set_value();
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
        void QueueDispatcher::set_automatic()
        {
            m_manual = false;
            // Execute in new thread
            t_execution = std::thread(std::bind(&QueueDispatcher::execute_loop, this));
        }
    
        void QueueDispatcher::execute_loop()
        {
            while (!m_manual)
            {
                if (auto action = m_queue.waitfor_and_pop(100))
                {
                    action.get().set_value();
                }
            }
        }
    }