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

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2007-2017, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       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_VERSIONEDSLAVECM_H
      22             : #define CO_VERSIONEDSLAVECM_H
      23             : 
      24             : #include "objectCM.h"               // base class
      25             : #include "objectDataIStream.h"      // member
      26             : #include "objectSlaveDataOStream.h" // member
      27             : 
      28             : #include <lunchbox/mtQueue.h> // member
      29             : #include <lunchbox/pool.h>    // member
      30             : #include <lunchbox/thread.h>  // thread-safety macro
      31             : 
      32             : namespace co
      33             : {
      34             : class Node;
      35             : 
      36             : /**
      37             :  * An object change manager handling changes for versioned slave instances.
      38             :  */
      39             : class VersionedSlaveCM : public ObjectCM
      40             : {
      41             : public:
      42             :     VersionedSlaveCM(Object* object, uint32_t masterInstanceID);
      43             :     virtual ~VersionedSlaveCM();
      44             : 
      45          34 :     void init() override {}
      46             :     /** @name Versioning */
      47             :     //@{
      48             :     uint128_t commit(const uint32_t incarnation) override;
      49             :     uint128_t sync(const uint128_t& version) override;
      50             : 
      51             :     uint128_t getHeadVersion() const final;
      52        1366 :     uint128_t getVersion() const final { return _version; }
      53             :     //@}
      54             : 
      55         138 :     bool isMaster() const override { return false; }
      56          33 :     uint32_t getMasterInstanceID() const override { return _masterInstanceID; }
      57          34 :     void setMasterNode(NodePtr node) override { _master = node; }
      58          35 :     NodePtr getMasterNode() override { return _master; }
      59           0 :     bool addSlave(const MasterCMCommand&) override
      60             :     {
      61           0 :         LBDONTCALL;
      62           0 :         return false;
      63             :     }
      64           0 :     void removeSlaves(NodePtr) override {}
      65             :     void applyMapData(const uint128_t& version) override;
      66             :     void addInstanceDatas(const ObjectDataIStreamDeque&,
      67             :                           const uint128_t& startVersion) override;
      68             : 
      69             : private:
      70             :     /** The current version. */
      71             :     uint128_t _version;
      72             : 
      73             :     /** istream for receiving the current version */
      74             :     ObjectDataIStream* _currentIStream;
      75             : 
      76             :     /** The change queue. */
      77             :     lunchbox::MTQueue<ObjectDataIStream*> _queuedVersions;
      78             : 
      79             :     /** Cached input streams (+decompressor) */
      80             :     lunchbox::Pool<ObjectDataIStream> _iStreamCache;
      81             : 
      82             :     /** The output stream for slave object commits. */
      83             :     ObjectSlaveDataOStream _ostream;
      84             : 
      85             :     /** The node holding the master object. */
      86             :     NodePtr _master;
      87             : 
      88             :     /** The instance identifier of the master object. */
      89             :     uint32_t _masterInstanceID;
      90             : 
      91             :     void _syncToHead();
      92             :     void _releaseStream(ObjectDataIStream* stream);
      93             :     void _sendAck();
      94             : 
      95             :     /** Apply the data in the input stream to the object */
      96             :     void _unpackOneVersion(ObjectDataIStream* is);
      97             : 
      98             :     /* The command handlers. */
      99             :     bool _cmdData(ICommand& command);
     100             : 
     101          68 :     LB_TS_VAR(_cmdThread);
     102          68 :     LB_TS_VAR(_rcvThread);
     103             : };
     104             : }
     105             : 
     106             : #endif // CO_VERSIONEDSLAVECM_H

Generated by: LCOV version 1.11