LCOV - code coverage report
Current view: top level - co - commandQueue.h (source / functions) Hit Total Coverage
Test: Collage Lines: 2 2 100.0 %
Date: 2018-01-09 16:37:03 Functions: 3 3 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2005-2014, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *
       4             :  * This file is part of Collage <https://github.com/Eyescale/Collage>
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef CO_COMMANDQUEUE_H
      21             : #define CO_COMMANDQUEUE_H
      22             : 
      23             : #include <co/api.h>
      24             : #include <co/types.h>
      25             : #include <limits.h>
      26             : #include <lunchbox/thread.h>
      27             : 
      28             : namespace co
      29             : {
      30             : namespace detail
      31             : {
      32             : class CommandQueue;
      33             : }
      34             : 
      35             : /** A thread-safe, blocking queue for ICommand buffers. */
      36             : class CommandQueue : public boost::noncopyable
      37             : {
      38             : public:
      39             :     /**
      40             :      * Construct a new command queue.
      41             :      *
      42             :      * @param maxSize the maximum number of enqueued commands.
      43             :      * @version 1.0
      44             :      */
      45             :     CO_API explicit CommandQueue(const size_t maxSize = ULONG_MAX);
      46             : 
      47             :     /** Destruct a new command queue. @version 1.0 */
      48             :     CO_API virtual ~CommandQueue();
      49             : 
      50             :     /**
      51             :      * Push a command to the queue.
      52             :      *
      53             :      * @param command the command.
      54             :      * @version 1.0
      55             :      */
      56             :     CO_API virtual void push(const ICommand& command);
      57             : 
      58             :     /** Push a command to the front of the queue. @version 1.0 */
      59             :     CO_API virtual void pushFront(const ICommand& command);
      60             : 
      61             :     /**
      62             :      * Pop a command from the queue.
      63             :      *
      64             :      * @param timeout the time in ms to wait for the operation.
      65             :      * @return the next command in the queue, or an invalid ICommand on timeout.
      66             :      * @version 1.0
      67             :      */
      68             :     CO_API virtual ICommand pop(const uint32_t timeout = LB_TIMEOUT_INDEFINITE);
      69             : 
      70             :     /**
      71             :      * Pop all, but at least one command from the queue.
      72             :      *
      73             :      * @param timeout the time in ms to wait for the operation.
      74             :      * @return All commands in the queue.
      75             :      * @version 1.0
      76             :      */
      77             :     CO_API virtual ICommands popAll(
      78             :         const uint32_t timeout = LB_TIMEOUT_INDEFINITE);
      79             : 
      80             :     /**
      81             :      * Try to pop a command from the queue.
      82             :      *
      83             :      * @return the next command in the queue, or 0 if no command is queued.
      84             :      * @version 1.0
      85             :      */
      86             :     CO_API virtual ICommand tryPop();
      87             : 
      88             :     /**
      89             :      * @return <code>true</code> if the command queue is empty,
      90             :      *         <code>false</code> if not.
      91             :      * @version 1.0
      92             :      */
      93             :     CO_API bool isEmpty() const;
      94             : 
      95             :     /** Flush all pending commands. @version 1.0 */
      96             :     CO_API void flush();
      97             : 
      98             :     /** @return the size of the queue. @version 1.0 */
      99             :     CO_API size_t getSize() const;
     100             : 
     101             :     /** @internal trigger internal processing (message pump) */
     102       51572 :     virtual void pump(){};
     103             : 
     104         134 :     LB_TS_VAR(_thread);
     105             : 
     106             : private:
     107             :     detail::CommandQueue* const _impl;
     108             : };
     109             : }
     110             : 
     111             : #endif // CO_COMMANDQUEUE_H

Generated by: LCOV version 1.11