LCOV - code coverage report
Current view: top level - sc/source/filter/oox - threadpool.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 2 0.0 %
Date: 2014-04-11 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #ifndef SC_THREADPOOL_HXX
      11             : #define SC_THREADPOOL_HXX
      12             : 
      13             : #include <sal/config.h>
      14             : #include <salhelper/thread.hxx>
      15             : #include <osl/mutex.hxx>
      16             : #include <osl/conditn.hxx>
      17             : #include <rtl/ref.hxx>
      18             : #include <vector>
      19             : 
      20           0 : class ThreadTask
      21             : {
      22             : public:
      23           0 :     virtual      ~ThreadTask() {}
      24             :     virtual void doWork() = 0;
      25             : };
      26             : 
      27             : /// A very basic thread pool implementation
      28             : class ThreadPool
      29             : {
      30             : public:
      31             :                 ThreadPool( sal_Int32 nWorkers );
      32             :     virtual    ~ThreadPool();
      33             :     void        pushTask( ThreadTask *pTask /* takes ownership */ );
      34             :     void        waitUntilEmpty();
      35             :     void        waitUntilWorkersDone();
      36             : 
      37             : private:
      38             :     class ThreadWorker;
      39             :     friend class ThreadWorker;
      40             : 
      41             :     ThreadTask *waitForWork( osl::Condition &rNewWork );
      42             :     ThreadTask *popWork();
      43             : 
      44             :     osl::Mutex maGuard;
      45             :     osl::Condition maTasksEmpty;
      46             :     bool mbTerminate;
      47             :     std::vector< rtl::Reference< ThreadWorker > > maWorkers;
      48             :     std::vector< ThreadTask * >   maTasks;
      49             : };
      50             : 
      51             : #endif // SC_THREADPOOL_HXX
      52             : 
      53             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10