Collage  1.2.1
High-performance C++ library for developing object-oriented distributed applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
commandQueue.h
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 <lunchbox/thread.h>
26 #include <limits.h>
27 
28 namespace co
29 {
30 namespace detail { class CommandQueue; }
31 
33 class CommandQueue : public boost::noncopyable
34 {
35 public:
42  CO_API explicit CommandQueue( const size_t maxSize = ULONG_MAX );
43 
45  CO_API virtual ~CommandQueue();
46 
53  CO_API virtual void push( const ICommand& command );
54 
56  CO_API virtual void pushFront( const ICommand& command );
57 
65  CO_API virtual ICommand pop( const uint32_t timeout =
66  LB_TIMEOUT_INDEFINITE );
67 
75  CO_API virtual ICommands popAll( const uint32_t timeout =
76  LB_TIMEOUT_INDEFINITE );
77 
84  CO_API virtual ICommand tryPop();
85 
91  CO_API bool isEmpty() const;
92 
94  CO_API void flush();
95 
97  CO_API size_t getSize() const;
98 
100  virtual void pump() {};
101 
102  LB_TS_VAR( _thread );
103 
104 private:
105  detail::CommandQueue* const _impl;
106 };
107 }
108 
109 #endif //CO_COMMANDQUEUE_H
Defines export visibility macros for library Collage.
std::vector< ICommand > ICommands
A vector of input commands.
Definition: types.h:140
A thread-safe, blocking queue for ICommand buffers.
Definition: commandQueue.h:33
virtual CO_API ICommand pop(const uint32_t timeout=LB_TIMEOUT_INDEFINITE)
Pop a command from the queue.
virtual CO_API ICommands popAll(const uint32_t timeout=LB_TIMEOUT_INDEFINITE)
Pop all, but at least one command from the queue.
CO_API void flush()
Flush all pending commands.
A class managing received commands.
Definition: iCommand.h:43
virtual CO_API void push(const ICommand &command)
Push a command to the queue.
virtual CO_API void pushFront(const ICommand &command)
Push a command to the front of the queue.
CO_API CommandQueue(const size_t maxSize=ULONG_MAX)
Construct a new command queue.
CO_API size_t getSize() const
virtual CO_API ICommand tryPop()
Try to pop a command from the queue.
virtual CO_API ~CommandQueue()
Destruct a new command queue.
CO_API bool isEmpty() const