Collage  1.7.0
High-performance C++ library for developing object-oriented distributed applications.
buffer.h
1 
2 /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@gmail.com>
3  * 2012-2014, Stefan.Eilemann@epfl.ch
4  *
5  * This file is part of Collage <https://github.com/Eyescale/Collage>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 2.1 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef CO_BUFFER_H
22 #define CO_BUFFER_H
23 
24 #include <co/api.h>
25 #include <co/types.h>
26 
27 #include <lunchbox/buffer.h> // base class
28 #include <lunchbox/referenced.h> // base class
29 #include <lunchbox/thread.h> // LB_TS_VAR macro
30 
31 namespace co
32 {
33 namespace detail
34 {
35 class Buffer;
36 }
37 
46 class Buffer : public lunchbox::Bufferb, public lunchbox::Referenced
47 {
48 public:
50  CO_API explicit Buffer(BufferListener* listener = 0);
51 
53  CO_API virtual ~Buffer();
54 
56  CO_API bool isFree() const;
57 
58  void setUsed();
59 
60 private:
61  detail::Buffer* const _impl;
62  LB_TS_VAR(_writeThread);
63 
64  void notifyFree() override;
65 };
66 
67 std::ostream& operator<<(std::ostream&, const Buffer&);
68 }
69 
70 #endif // CO_BUFFER_H
Defines export visibility macros for library Collage.
A receive buffer for a Connection.
Definition: buffer.h:46
Object-oriented network library.
Definition: barrier.h:27
A listener interface to buffer state changes.