LCOV - code coverage report
Current view: top level - co - worker.ipp (source / functions) Hit Total Coverage
Test: Collage Lines: 17 18 94.4 %
Date: 2018-01-09 16:37:03 Functions: 1 1 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011-2013, Stefan Eilemann <eile@eyescale.ch>
       3             :  *                    2012, Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #include "worker.h"
      20             : 
      21             : #include "iCommand.h"
      22             : 
      23             : namespace co
      24             : {
      25             : template <class Q>
      26       51655 : void WorkerThread<Q>::run()
      27             : {
      28      103262 :     while (!stopRunning())
      29             :     {
      30       51608 :         while (_commands.isEmpty())
      31       51502 :             if (!notifyIdle()) // nothing to do
      32       51502 :                 break;
      33             : 
      34      103215 :         const ICommands& commands = _commands.popAll();
      35       51607 :         LBASSERT(!commands.empty());
      36             : 
      37      103179 :         for (ICommandsCIter i = commands.begin(); i != commands.end(); ++i)
      38             :         {
      39             :             // We want to avoid a non-const copy of commands, hence the cast...
      40       51619 :             ICommand& command = const_cast<ICommand&>(*i);
      41       51619 :             if (!command())
      42             :             {
      43           0 :                 LBABORT("Error handling " << command);
      44             :             }
      45       51619 :             if (stopRunning())
      46          47 :                 break;
      47             : 
      48       51572 :             _commands.pump();
      49             :         }
      50             :     }
      51             : 
      52          47 :     _commands.flush();
      53          94 :     LBDEBUG << "Leaving worker thread " << lunchbox::className(this)
      54          47 :             << std::endl;
      55          47 : }
      56             : }

Generated by: LCOV version 1.11