VirtualBox

Changeset 71526 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Mar 27, 2018 4:01:42 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Small cleanup for UIThreadPool.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/globals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIThreadPool.cpp

    r69500 r71526  
    55
    66/*
    7  * Copyright (C) 2013-2017 Oracle Corporation
     7 * Copyright (C) 2013-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2525/* GUI includes: */
    2626# include "COMDefs.h"
     27# include "UIDefs.h"
    2728# include "UIThreadPool.h"
    28 # include "UIDefs.h"
    2929
    3030/* Other VBox includes: */
     
    3232
    3333#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     34
    3435
    3536/** QThread extension used as worker-thread.
     
    4748
    4849    /** Constructs worker-thread for parent worker-thread @a pPool.
    49       * @param iIndex defines worker-thread index within the worker-thread pool registry. */
     50      * @param  iIndex  Brings worker-thread index within the worker-thread pool registry. */
    5051    UIThreadWorker(UIThreadPool *pPool, int iIndex);
    5152
     
    7071    bool m_fNoFinishedSignal;
    7172};
     73
     74
     75/*********************************************************************************************************************************
     76*   Class UIThreadPool implementation.                                                                                           *
     77*********************************************************************************************************************************/
    7278
    7379UIThreadPool::UIThreadPool(ulong cMaxWorkers /* = 3 */, ulong cMsWorkerIdleTimeout /* = 5000 */)
     
    207213}
    208214
    209 UITask* UIThreadPool::dequeueTask(UIThreadWorker *pWorker)
     215UITask *UIThreadPool::dequeueTask(UIThreadWorker *pWorker)
    210216{
    211217    /* Lock initially: */
     
    301307}
    302308
     309
     310/*********************************************************************************************************************************
     311*   Class UIThreadWorker implementation.                                                                                         *
     312*********************************************************************************************************************************/
     313
    303314UIThreadWorker::UIThreadWorker(UIThreadPool *pPool, int iIndex)
    304315    : m_pPool(pPool)
     
    332343}
    333344
     345
    334346#include "UIThreadPool.moc"
    335347
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIThreadPool.h

    r69500 r71526  
    55
    66/*
    7  * Copyright (C) 2013-2017 Oracle Corporation
     7 * Copyright (C) 2013-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020
    2121/* Qt includes: */
     22#include <QMutex>
    2223#include <QObject>
    23 #include <QMutex>
    2424#include <QQueue>
    2525#include <QSet>
     
    2929
    3030/* Forward declarations: */
     31class UITask;
    3132class UIThreadWorker;
    32 class UITask;
     33
    3334
    3435/** QObject extension used as worker-thread pool.
     
    4647
    4748    /** Constructs worker-thread pool.
    48       * @param cMaxWorkers          defines the maximum amount of worker-threads.
    49       * @param cMsWorkerIdleTimeout defines the maximum amount of time (in ms) which
    50       *                             pool will wait for the worker-thread on cleanup. */
     49      * @param  cMaxWorkers           Brings the maximum amount of worker-threads.
     50      * @param  cMsWorkerIdleTimeout  Brings the maximum amount of time (in ms) which
     51      *                               pool will wait for the worker-thread on cleanup. */
    5152    UIThreadPool(ulong cMaxWorkers = 3, ulong cMsWorkerIdleTimeout = 5000);
    5253    /** Destructs worker-thread pool. */
     
    6061    /** Enqueues @a pTask into the task-queue. */
    6162    void enqueueTask(UITask *pTask);
    62     /** Returns dequeued top-most task from the task-queue.
    63       * @remarks Called by the @a pWorker passed as a hint. */
    64     UITask* dequeueTask(UIThreadWorker *pWorker);
     63    /** Returns dequeued top-most task from the task-queue. */
     64    UITask *dequeueTask(UIThreadWorker *pWorker);
    6565
    6666private slots:
     
    7878        /** Holds the maximum amount of time (in ms) which
    7979          * pool will wait for the worker-thread on cleanup. */
    80         const ulong m_cMsIdleTimeout;
     80        const ulong               m_cMsIdleTimeout;
    8181        /** Holds the vector of worker-threads. */
    82         QVector<UIThreadWorker*> m_workers;
     82        QVector<UIThreadWorker*>  m_workers;
    8383        /** Holds the number of worker-threads.
    8484          * @remarks We cannot use the vector size since it may contain 0 pointers. */
    85         int m_cWorkers;
     85        int                       m_cWorkers;
    8686        /** Holds the number of idle worker-threads. */
    87         int m_cIdleWorkers;
     87        int                       m_cIdleWorkers;
    8888        /** Holds whether the 'termination sequence' is started
    8989          * and all worker-threads should terminate ASAP. */
    90         bool m_fTerminating;
     90        bool                      m_fTerminating;
    9191    /** @} */
    9292
     
    9494     * @{ */
    9595        /** Holds the queue of pending tasks. */
    96         QQueue<UITask*> m_pendingTasks;
     96        QQueue<UITask*>  m_pendingTasks;
    9797        /** Holds the set of executing tasks. */
    98         QSet<UITask*> m_executingTasks;
     98        QSet<UITask*>    m_executingTasks;
    9999        /** Holds the condition variable that gets signalled when
    100100          * queuing a new task and there are idle worker threads around.
     
    103103          *          broadcast signal to wake up all workers (after
    104104          *          setting m_fTerminating of course). */
    105         QWaitCondition m_taskCondition;
     105        QWaitCondition   m_taskCondition;
    106106    /** @} */
    107107
     
    110110    mutable QMutex m_everythingLocker;
    111111};
     112
    112113
    113114/** QObject extension used as worker-thread task interface.
     
    131132    };
    132133
    133     /** Constructs the task of passed @a type. */
    134     UITask(UITask::Type type) : m_type(type) {}
     134    /** Constructs the task of passed @a enmType. */
     135    UITask(UITask::Type enmType) : m_enmType(enmType) {}
    135136
    136137    /** Returns the type of the task. */
    137     UITask::Type type() const { return m_type; }
     138    UITask::Type type() const { return m_enmType; }
    138139
    139140    /** Starts the task. */
     
    142143protected:
    143144
    144     /** Contains the abstract task body.
    145       * @remarks To be reimplemented in sub-class. */
     145    /** Contains the abstract task body. */
    146146    virtual void run() = 0;
    147147
     
    149149
    150150    /** Holds the type of the task. */
    151     const UITask::Type m_type;
     151    const UITask::Type m_enmType;
    152152};
     153
    153154
    154155#endif /* !___UIThreadPool_h___ */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette