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

          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_PIPE_CONNECTION_H
      21             : #define CO_PIPE_CONNECTION_H
      22             : 
      23             : #ifdef _WIN32
      24             : #include <co/namedPipeConnection.h>
      25             : #else
      26             : #include "fdConnection.h"
      27             : #endif
      28             : 
      29             : #include <lunchbox/monitor.h>
      30             : #include <lunchbox/thread.h>
      31             : 
      32             : namespace co
      33             : {
      34             : class NamedPipeConnection;
      35             : class PipeConnection;
      36             : typedef lunchbox::RefPtr<PipeConnection> PipeConnectionPtr;
      37             : typedef lunchbox::RefPtr<const PipeConnection> ConstPipeConnectionPtr;
      38             : 
      39             : /**
      40             :  * An inter-thread, bi-directional connection using anonymous pipes.
      41             :  *
      42             :  * The pipe connection is implemented using anonymous pipes, and can
      43             :  * therefore only be used between related threads. It consist of a pair of
      44             :  * siblings representing the two endpoints.
      45             :  */
      46             : class PipeConnection
      47             : #ifdef _WIN32
      48             :     : public Connection
      49             : #else
      50             :     : public FDConnection
      51             : #endif
      52             : {
      53             : public:
      54             :     /** Construct a new pipe connection. */
      55             :     CO_API PipeConnection();
      56             :     /** Destruct this pipe connection. */
      57             :     CO_API virtual ~PipeConnection();
      58             : 
      59             :     bool connect() override;
      60         161 :     void close() override { _close(); }
      61             : #ifdef _WIN32
      62             :     Notifier getNotifier() const override;
      63             : #endif
      64             : 
      65           0 :     void acceptNB() override { /* nop */}
      66             : 
      67             :     /** @return the sibling of this pipe connection. */
      68             :     ConnectionPtr acceptSync() override;
      69             : 
      70             :     /** @return the sibling connection. */
      71          95 :     PipeConnectionPtr getSibling() { return _sibling; }
      72             : protected:
      73             : #ifdef _WIN32
      74             :     void readNB(void* buffer, const uint64_t bytes) override;
      75             :     int64_t readSync(void* buffer, const uint64_t bytes,
      76             :                      const bool ignored) override;
      77             :     int64_t write(const void* buffer, const uint64_t bytes) override;
      78             : #endif
      79             : 
      80             : private:
      81             :     PipeConnectionPtr _sibling;
      82             :     lunchbox::Monitorb _connected;
      83             : 
      84             : #ifdef _WIN32
      85             :     NamedPipeConnectionPtr _namedPipe;
      86             : 
      87             :     LB_TS_VAR(_recvThread);
      88             : #endif
      89             : 
      90             :     bool _createPipes();
      91             :     void _close();
      92             : };
      93             : }
      94             : 
      95             : #endif // CO_PIPE_CONNECTION_H

Generated by: LCOV version 1.11