Line data Source code
1 :
2 : /* Copyright (c) 2010-2017, 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_EVENT_CONNECTION_H
21 : #define CO_EVENT_CONNECTION_H
22 :
23 : #include <co/connection.h> // base class
24 :
25 : #include "buffer.h"
26 : #include "pipeConnection.h"
27 :
28 : namespace co
29 : {
30 : /**
31 : * A connection signalling an event.
32 : *
33 : * The connection is only useful to signal something to a ConnectionSet. No data
34 : * can be read or written from it.
35 : */
36 : class EventConnection : public Connection
37 : {
38 : public:
39 : CO_API EventConnection();
40 : CO_API virtual ~EventConnection();
41 :
42 : CO_API bool connect() override;
43 52 : CO_API void close() override { _close(); }
44 : CO_API void set();
45 : CO_API void reset();
46 :
47 : CO_API Notifier getNotifier() const override;
48 :
49 : protected:
50 0 : void readNB(void*, const uint64_t) override { LBDONTCALL; }
51 0 : int64_t readSync(void*, const uint64_t, const bool) override
52 : {
53 0 : LBDONTCALL;
54 0 : return -1;
55 : }
56 0 : CO_API int64_t write(const void*, const uint64_t) override
57 : {
58 0 : LBDONTCALL;
59 0 : return -1;
60 : }
61 :
62 : private:
63 : #ifdef _WIN32
64 : void* _event;
65 : #else
66 : PipeConnectionPtr _connection;
67 : std::mutex _lock;
68 : bool _set;
69 : #endif
70 :
71 : Buffer _buffer;
72 :
73 : void _close();
74 : };
75 : }
76 :
77 : #endif // CO_EVENT_CONNECTION_H
|