Changeset 114:8b171b809697 in finroc_plugins_data_ports


Ignore:
Timestamp:
07.06.2017 22:48:17 (6 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Rebase:
34343030376135656463383463303563336530363139663765366161613634643038333935346330
Message:

Removes obsolete reverse pushing mechanism (as this is an unused feature in C++ that comes with a performance penalty, makes the implementation more complex, and does not properly work with the new type conversion feature).

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • api/tGenericPortImplementation.cpp

    r106 r114  
    200200      buffer->GetObject().DeepCopyFrom(data); 
    201201      common::tPublishOperation<optimized::tCheapCopyPort, typename optimized::tCheapCopyPort::tPublishingDataThreadLocalBuffer> publish_operation(buffer.release(), true); 
    202       publish_operation.Execute<false, tChangeStatus::CHANGED, false, false>(static_cast<tPortBase&>(port)); 
     202      publish_operation.Execute<tChangeStatus::CHANGED, false, false>(static_cast<tPortBase&>(port)); 
    203203    } 
    204204    else 
     
    208208      buffer->GetObject().DeepCopyFrom(data); 
    209209      common::tPublishOperation<optimized::tCheapCopyPort, typename optimized::tCheapCopyPort::tPublishingDataGlobalBuffer> publish_operation(buffer); 
    210       publish_operation.Execute<false, tChangeStatus::CHANGED, false, false>(static_cast<tPortBase&>(port)); 
     210      publish_operation.Execute<tChangeStatus::CHANGED, false, false>(static_cast<tPortBase&>(port)); 
    211211    } 
    212212#else 
  • api/tGenericPortImplementation.h

    r106 r114  
    193193      { 
    194194        common::tPublishOperation<optimized::tCheapCopyPort, typename optimized::tCheapCopyPort::tPublishingDataThreadLocalBuffer> publish_operation(static_cast<optimized::tThreadLocalBufferManager*>(data_buffer.implementation.Release()), true); 
    195         publish_operation.Execute<false, tChangeStatus::CHANGED, false, false>(cc_port); 
     195        publish_operation.Execute<tChangeStatus::CHANGED, false, false>(cc_port); 
    196196      } 
    197197      else 
     
    199199        optimized::tCheapCopyPort::tUnusedManagerPointer pointer(static_cast<optimized::tCheaplyCopiedBufferManager*>(data_buffer.implementation.Release())); 
    200200        common::tPublishOperation<optimized::tCheapCopyPort, typename optimized::tCheapCopyPort::tPublishingDataGlobalBuffer> publish_operation(pointer); 
    201         publish_operation.Execute<false, tChangeStatus::CHANGED, false, false>(cc_port); 
     201        publish_operation.Execute<tChangeStatus::CHANGED, false, false>(cc_port); 
    202202      } 
    203203#else 
  • api/tPortImplementation.h

    r101 r114  
    198198      tBase::Assign(buffer->GetObject().GetData<typename tBase::tPortBuffer>(), data); 
    199199      common::tPublishOperation<optimized::tCheapCopyPort, typename optimized::tCheapCopyPort::tPublishingDataThreadLocalBuffer> publish_operation(buffer.release(), true); 
    200       publish_operation.Execute<false, tChangeStatus::CHANGED, false, false>(port); 
     200      publish_operation.Execute<tChangeStatus::CHANGED, false, false>(port); 
    201201    } 
    202202    else 
     
    206206      tBase::Assign(buffer->GetObject().GetData<typename tBase::tPortBuffer>(), data); 
    207207      common::tPublishOperation<optimized::tCheapCopyPort, typename optimized::tCheapCopyPort::tPublishingDataGlobalBuffer> publish_operation(buffer); 
    208       publish_operation.Execute<false, tChangeStatus::CHANGED, false, false>(port); 
     208      publish_operation.Execute<tChangeStatus::CHANGED, false, false>(port); 
    209209    } 
    210210  } 
  • common/tAbstractDataPort.cpp

    r107 r114  
    102102} 
    103103 
    104 void tAbstractDataPort::ConsiderInitialReversePush(tAbstractDataPort& target) 
    105 { 
    106   if (IsReady() && target.IsReady()) 
    107   { 
    108     if (ReversePushStrategy() && CountOutgoingConnections() == 1) 
    109     { 
    110       FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "Performing initial reverse push from ", target, " to ", (*this)); 
    111       target.InitialPushTo(*this, true); 
    112     } 
    113   } 
    114 } 
    115  
    116104core::tConnector* tAbstractDataPort::CreateConnector(tAbstractPort& destination, const core::tConnectOptions& connect_options) 
    117105{ 
     
    165153  { 
    166154    (static_cast<tAbstractDataPort&>(partner)).PropagateStrategy(nullptr, this); 
    167  
    168     // check whether we need an initial reverse push 
    169     this->ConsiderInitialReversePush(static_cast<tAbstractDataPort&>(partner)); 
    170155  } 
    171156} 
     
    224209  { 
    225210    bool source_port = (strategy >= 1 && max >= 1) || (!HasIncomingConnections()); 
    226     if (!source_port) 
    227     { 
    228       bool all_sources_reverse_pushers = true; 
    229       for (auto it = IncomingConnectionsBegin(); it != IncomingConnectionsEnd(); ++it) 
    230       { 
    231         tAbstractDataPort& port = static_cast<tAbstractDataPort&>(it->Source()); 
    232         if (port.IsReady() && (!port.ReversePushStrategy())) 
    233         { 
    234           all_sources_reverse_pushers = false; 
    235           break; 
    236         } 
    237       } 
    238       source_port = all_sources_reverse_pushers; 
    239     } 
    240211    if (source_port) 
    241212    { 
     
    243214      { 
    244215        FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "Performing initial push from ", (*this), " to ", (*push_wanter)); 
    245         InitialPushTo(*push_wanter, false); 
     216 
     217        // find connector 
     218        bool pushed = false; 
     219        for (auto it = OutgoingConnectionsBegin(); it != OutgoingConnectionsEnd(); ++it) 
     220        { 
     221          if (&it->Destination() == push_wanter) 
     222          { 
     223            InitialPushTo(*it); 
     224            pushed = true; 
     225            break; 
     226          } 
     227        } 
     228        if (!pushed) 
     229        { 
     230          FINROC_LOG_PRINT(DEBUG_WARNING, "Connector not found -> not initial pushing (programming error)"); 
     231        } 
     232 
    246233      } 
    247       push_wanter = NULL; 
     234      push_wanter = nullptr; 
    248235    } 
    249236  } 
     
    251238  // okay... do we wish to receive a push? 
    252239  // yes if... 
    253   //  1) we are target of a new connection, have a push strategy, no other sources, and partner is no reverse push source 
     240  //  1) we are target of a new connection, have a push strategy, and no other sources 
    254241  //  2) our strategy changed to push, and exactly one source 
    255242  int other_sources = 0; 
     
    261248    } 
    262249  } 
    263   bool request_push = (new_connection_partner && (max >= 1) && (other_sources == 0) && (!new_connection_partner->ReversePushStrategy())) || ((max >= 1 && strategy < 1) && (other_sources == 1)); 
     250  bool request_push = (new_connection_partner && (max >= 1) && (other_sources == 0)) || ((max >= 1 && strategy < 1) && (other_sources == 1)); 
    264251 
    265252  // register strategy change 
     
    301288} 
    302289 
    303 void tAbstractDataPort::SetReversePushStrategy(bool push) 
    304 { 
    305   if (push == GetFlag(tFlag::PUSH_STRATEGY_REVERSE)) 
    306   { 
    307     return; 
    308   } 
    309  
    310   tLock lock(GetStructureMutex()); 
    311   SetFlag(tFlag::PUSH_STRATEGY_REVERSE, push); 
    312   if (push && IsReady())    // strategy change 
    313   { 
    314     for (auto it = OutgoingConnectionsBegin(); it != OutgoingConnectionsEnd(); ++it) 
    315     { 
    316       tAbstractDataPort& port = static_cast<tAbstractDataPort&>(it->Destination()); 
    317       if (port.IsReady()) 
    318       { 
    319         FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "Performing initial reverse push from ", port, " to ", (*this)); 
    320         port.InitialPushTo(*this, true); 
    321         break; 
    322       } 
    323     } 
    324   } 
    325   this->PublishUpdatedInfo(core::tRuntimeListener::tEvent::CHANGE); 
    326 } 
    327  
    328290void tAbstractDataPort::UpdateEdgeStatistics(tAbstractPort& source, tAbstractPort& target, rrlib::rtti::tGenericObject& data) 
    329291{ 
  • common/tAbstractDataPort.h

    r107 r114  
    168168 
    169169  /*! 
    170    * \return Is data to this port pushed or pulled (in reverse direction)? 
    171    */ 
    172   inline bool ReversePushStrategy() const 
    173   { 
    174     return GetFlag(tFlag::PUSH_STRATEGY_REVERSE); 
    175   } 
    176  
    177   /*! 
    178170   * \param new_value New value for custom changed flag (for use by custom API - not used/accessed by core port classes.) 
    179171   */ 
     
    209201  void SetPushStrategy(bool push); 
    210202 
    211   /*! 
    212    * Set whether data should be pushed or pulled in reverse direction 
    213    * 
    214    * \param push Push data? 
    215    */ 
    216   void SetReversePushStrategy(bool push); 
    217  
    218203//---------------------------------------------------------------------- 
    219204// Protected methods 
     
    257242   * Does this port "want" to receive a value via push strategy? 
    258243   * 
    259    * \param cReverse direction? (typically we push forward) 
    260    * \param change_constant If this is about an initial push, this should be CHANGED_INITIAL - otherwise CHANGED 
     244   * \tparam cCHANGE_CONSTANT change_constant If this is about an initial push, this should be CHANGED_INITIAL - otherwise CHANGED 
    261245   * \return Answer 
    262246   * 
     
    264248   * (Standard implementation for this) 
    265249   */ 
    266   template <bool cREVERSE, tChangeStatus cCHANGE_CONSTANT> 
     250  template <tChangeStatus cCHANGE_CONSTANT> 
    267251  inline bool WantsPush() const 
    268252  { 
    269     // The compiler should optimize branches away 
    270     if (cREVERSE) 
    271     { 
    272       if (cCHANGE_CONSTANT == tChangeStatus::CHANGED_INITIAL) 
    273       { 
    274         return GetFlag(tFlag::PUSH_STRATEGY_REVERSE) && CountOutgoingConnections() <= 1; 
    275       } 
    276       else 
    277       { 
    278         return GetFlag(tFlag::PUSH_STRATEGY_REVERSE); 
    279       } 
    280     } 
    281     else if (cCHANGE_CONSTANT == tChangeStatus::CHANGED_INITIAL) 
     253    if (cCHANGE_CONSTANT == tChangeStatus::CHANGED_INITIAL) 
    282254    { 
    283255      // We don't want initial pushes to ports with multiple inputs 
     
    333305 
    334306  /*! 
    335    * Should be called in situations where there might need to be an initial push 
    336    * (e.g. connecting or strategy change) 
    337    * 
    338    * \param target Potential Target port 
    339    */ 
    340   void ConsiderInitialReversePush(tAbstractDataPort& target); 
    341  
    342   /*! 
    343307   * Forward current strategy to source ports (helper for above - and possibly variations of above) 
    344308   * 
     
    360324 
    361325  /*! 
    362    * Push initial value to the specified port 
    363    * (checks etc. have been done by AbstractDataPort class) 
    364    * 
    365    * \param target Port to push data to 
    366    * \param reverse Is this a reverse push? 
    367    */ 
    368   virtual void InitialPushTo(tAbstractPort& target, bool reverse) = 0; 
     326   * Push initial value to destination port 
     327   * (checks etc. have been done by tAbstractDataPort class) 
     328   * 
     329   * \param connector Connector connecting both ports 
     330   */ 
     331  virtual void InitialPushTo(core::tConnector& connector) = 0; 
    369332 
    370333  virtual void OnConnect(tAbstractPort& partner, bool partner_is_destination) override; 
  • common/tPublishOperation.h

    r107 r114  
    9292   * 
    9393   * \param port (Output) port to perform publishing operation on 
    94    * \tparam REVERSE Publish in reverse direction? (typical is forward) 
    9594   * \tparam CHANGE_CONSTANT changedConstant to use 
    96    * \tparam BROWSER_PUBLISH Inform this port's listeners on change and also publish in reverse direction? (only set from BrowserPublish()) 
     95   * \tparam BROWSER_PUBLISH Inform this port's listeners on change? (only set from BrowserPublish()) 
    9796   */ 
    98   template <bool REVERSE, tChangeStatus CHANGE_CONSTANT, bool BROWSER_PUBLISH, bool NOTIFY_LISTENER_ON_THIS_PORT> 
     97  template <tChangeStatus CHANGE_CONSTANT, bool BROWSER_PUBLISH, bool NOTIFY_LISTENER_ON_THIS_PORT> 
    9998  inline void Execute(TPort& port) 
    10099  { 
     
    128127#endif 
    129128 
    130     if (!REVERSE) 
    131     { 
    132       for (auto it = port.OutgoingConnectionsBegin(); it != port.OutgoingConnectionsEnd(); ++it) 
     129    for (auto it = port.OutgoingConnectionsBegin(); it != port.OutgoingConnectionsEnd(); ++it) 
     130    { 
     131      if (static_cast<const common::tAbstractDataPort&>(it->Destination()).template WantsPush<CHANGE_CONSTANT>()) 
    133132      { 
    134         if (static_cast<const common::tAbstractDataPort&>(it->Destination()).template WantsPush<REVERSE, CHANGE_CONSTANT>()) 
    135         { 
    136           if (it->Flags().Get(core::tConnectionFlag::CONVERSION)) 
    137           { 
    138             static_cast<const tConversionConnector&>(*it).Publish(this->GetObject(), CHANGE_CONSTANT); 
    139           } 
    140           else 
    141           { 
    142             TPort& destination_port = static_cast<TPort&>(it->Destination()); 
    143             Receive<REVERSE, CHANGE_CONSTANT>(*this, destination_port, port); 
    144           } 
    145         } 
    146       } 
    147     } 
    148  
    149     if (REVERSE || BROWSER_PUBLISH) 
    150     { 
    151       // reverse 
    152       for (auto it = port.IncomingConnectionsBegin(); it != port.IncomingConnectionsEnd(); ++it) 
    153       { 
    154         if (static_cast<const common::tAbstractDataPort&>(it->Source()).template WantsPush<true, CHANGE_CONSTANT>() && (!it->Flags().Get(core::tConnectionFlag::CONVERSION))) 
    155         { 
    156           TPort& destination_port = static_cast<TPort&>(it->Source()); 
    157           Receive<true, CHANGE_CONSTANT>(*this, destination_port, port); 
     133        if (it->Flags().Get(core::tConnectionFlag::CONVERSION)) 
     134        { 
     135          static_cast<const tConversionConnector&>(*it).Publish(this->GetObject(), CHANGE_CONSTANT); 
     136        } 
     137        else 
     138        { 
     139          TPort& destination_port = static_cast<TPort&>(it->Destination()); 
     140          Receive<CHANGE_CONSTANT>(*this, destination_port, port); 
    158141        } 
    159142      } 
     
    165148   * \param port Port that receives data 
    166149   * \param origin Port that value was received from 
    167    * \tparam REVERSE Publish in reverse direction? (typical is forward) 
    168150   * \tparam CHANGE_CONSTANT changedConstant to use 
    169151   */ 
    170   template <bool REVERSE, tChangeStatus CHANGE_CONSTANT> 
     152  template <tChangeStatus CHANGE_CONSTANT> 
    171153  static inline void Receive(typename std::conditional<TPublishingData::cCOPY_ON_RECEIVE, TPublishingData, TPublishingData&>::type publishing_data, TPort& port, TPort& origin) 
    172154  { 
     
    179161    port.UpdateStatistics(publishing_data, origin, port); 
    180162 
    181     if (!REVERSE) 
    182     { 
    183       // forward 
    184       for (auto it = port.OutgoingConnectionsBegin(); it != port.OutgoingConnectionsEnd(); ++it) 
     163    // forward 
     164    for (auto it = port.OutgoingConnectionsBegin(); it != port.OutgoingConnectionsEnd(); ++it) 
     165    { 
     166      if (static_cast<const common::tAbstractDataPort&>(it->Destination()).template WantsPush<CHANGE_CONSTANT>()) 
    185167      { 
    186         if (static_cast<const common::tAbstractDataPort&>(it->Destination()).template WantsPush<REVERSE, CHANGE_CONSTANT>()) 
    187         { 
    188           if (it->Flags().Get(core::tConnectionFlag::CONVERSION)) 
    189           { 
    190             static_cast<const tConversionConnector&>(*it).Publish(publishing_data.GetObject(), CHANGE_CONSTANT); 
    191           } 
    192           else 
    193           { 
    194             TPort& destination_port = static_cast<TPort&>(it->Destination()); 
    195             Receive<false, CHANGE_CONSTANT>(publishing_data, destination_port, port); 
    196           } 
    197         } 
    198       } 
    199  
    200       // reverse 
    201       for (auto it = port.IncomingConnectionsBegin(); it != port.IncomingConnectionsEnd(); ++it) 
    202       { 
    203         if (&it->Source() != &origin && static_cast<const common::tAbstractDataPort&>(it->Source()).template WantsPush<true, CHANGE_CONSTANT>() && (!it->Flags().Get(core::tConnectionFlag::CONVERSION))) 
    204         { 
    205           TPort& destination_port = static_cast<TPort&>(it->Source()); 
    206           Receive<true, CHANGE_CONSTANT>(publishing_data, destination_port, port); 
     168        if (it->Flags().Get(core::tConnectionFlag::CONVERSION)) 
     169        { 
     170          static_cast<const tConversionConnector&>(*it).Publish(publishing_data.GetObject(), CHANGE_CONSTANT); 
     171        } 
     172        else 
     173        { 
     174          TPort& destination_port = static_cast<TPort&>(it->Destination()); 
     175          Receive<CHANGE_CONSTANT>(publishing_data, destination_port, port); 
    207176        } 
    208177      } 
  • optimized/tCheapCopyPort.cpp

    r106 r114  
    170170      if (change_constant == tChangeStatus::CHANGED_INITIAL) 
    171171      { 
    172         data.Execute<false, tChangeStatus::CHANGED_INITIAL, true, true>(*this); 
     172        data.Execute<tChangeStatus::CHANGED_INITIAL, true, true>(*this); 
    173173      } 
    174174      else 
    175175      { 
    176         data.Execute<false, tChangeStatus::CHANGED, true, true>(*this); 
     176        data.Execute<tChangeStatus::CHANGED, true, true>(*this); 
    177177      } 
    178178    } 
     
    181181      if (change_constant == tChangeStatus::CHANGED_INITIAL) 
    182182      { 
    183         data.Execute<false, tChangeStatus::CHANGED_INITIAL, true, false>(*this); 
     183        data.Execute<tChangeStatus::CHANGED_INITIAL, true, false>(*this); 
    184184      } 
    185185      else 
    186186      { 
    187         data.Execute<false, tChangeStatus::CHANGED, true, false>(*this); 
     187        data.Execute<tChangeStatus::CHANGED, true, false>(*this); 
    188188      } 
    189189    } 
     
    196196      if (change_constant == tChangeStatus::CHANGED_INITIAL) 
    197197      { 
    198         data.Execute<false, tChangeStatus::CHANGED_INITIAL, true, true>(*this); 
     198        data.Execute<tChangeStatus::CHANGED_INITIAL, true, true>(*this); 
    199199      } 
    200200      else 
    201201      { 
    202         data.Execute<false, tChangeStatus::CHANGED, true, true>(*this); 
     202        data.Execute<tChangeStatus::CHANGED, true, true>(*this); 
    203203      } 
    204204    } 
     
    207207      if (change_constant == tChangeStatus::CHANGED_INITIAL) 
    208208      { 
    209         data.Execute<false, tChangeStatus::CHANGED_INITIAL, true, false>(*this); 
     209        data.Execute<tChangeStatus::CHANGED_INITIAL, true, false>(*this); 
    210210      } 
    211211      else 
    212212      { 
    213         data.Execute<false, tChangeStatus::CHANGED, true, false>(*this); 
     213        data.Execute<tChangeStatus::CHANGED, true, false>(*this); 
    214214      } 
    215215    } 
     
    278278    { 
    279279      common::tPublishOperation<tCheapCopyPort, tPublishingDataThreadLocalBuffer> data(static_cast<tThreadLocalBufferManager*>(current_buffer.GetPointer()), false); 
    280       data.Execute<false, tChangeStatus::CHANGED, false, false>(static_cast<tCheapCopyPort&>(other)); 
     280      data.Execute<tChangeStatus::CHANGED, false, false>(static_cast<tCheapCopyPort&>(other)); 
    281281      return; 
    282282    } 
     
    294294      { 
    295295        common::tPublishOperation<tCheapCopyPort, tPublishingDataThreadLocalBuffer> data(static_cast<tThreadLocalBufferManager*>(current_buffer.GetPointer()), true); 
    296         data.Execute<false, tChangeStatus::CHANGED, false, false>(static_cast<tCheapCopyPort&>(other)); 
     296        data.Execute<tChangeStatus::CHANGED, false, false>(static_cast<tCheapCopyPort&>(other)); 
    297297        return; 
    298298      } 
     
    305305    CopyCurrentValueToManager(*unused_manager, tStrategy::NEVER_PULL); 
    306306    common::tPublishOperation<tCheapCopyPort, tPublishingDataGlobalBuffer> data(unused_manager); 
    307     data.Execute<false, tChangeStatus::CHANGED, false, false>(static_cast<tCheapCopyPort&>(other)); 
     307    data.Execute<tChangeStatus::CHANGED, false, false>(static_cast<tCheapCopyPort&>(other)); 
    308308  } 
    309309} 
     
    379379// 
    380380 
    381 void tCheapCopyPort::InitialPushTo(tAbstractPort& target, bool reverse) 
     381void tCheapCopyPort::InitialPushTo(core::tConnector& connector) 
    382382{ 
    383383  // this is a one-time event => use global buffer 
     
    385385  CopyCurrentValueToManager(*unused_manager, tStrategy::NEVER_PULL); 
    386386  common::tPublishOperation<tCheapCopyPort, tPublishingDataGlobalBuffer> data(unused_manager); 
    387   tCheapCopyPort& target_port = static_cast<tCheapCopyPort&>(target); 
    388   if (reverse) 
    389   { 
    390     common::tPublishOperation<tCheapCopyPort, tPublishingDataGlobalBuffer>::Receive<true, tChangeStatus::CHANGED_INITIAL>(data, target_port, *this); 
    391   } 
    392   else 
    393   { 
    394     common::tPublishOperation<tCheapCopyPort, tPublishingDataGlobalBuffer>::Receive<false, tChangeStatus::CHANGED_INITIAL>(data, target_port, *this); 
    395   } 
     387  tCheapCopyPort& target_port = static_cast<tCheapCopyPort&>(connector.Destination()); 
     388  common::tPublishOperation<tCheapCopyPort, tPublishingDataGlobalBuffer>::Receive<tChangeStatus::CHANGED_INITIAL>(data, target_port, *this); 
    396389} 
    397390 
  • optimized/tCheapCopyPort.h

    r107 r114  
    819819//  } 
    820820 
    821   virtual void InitialPushTo(tAbstractPort& target, bool reverse) override; 
     821  virtual void InitialPushTo(core::tConnector& connector) override; 
    822822 
    823823  /*! 
  • optimized/tSingleThreadedCheapCopyPortGeneric.cpp

    r106 r114  
    126126    if (change_constant == tChangeStatus::CHANGED_INITIAL) 
    127127    { 
    128       publish_operation.Execute<false, tChangeStatus::CHANGED_INITIAL, true, true>(*this); 
     128      publish_operation.Execute<tChangeStatus::CHANGED_INITIAL, true, true>(*this); 
    129129    } 
    130130    else 
    131131    { 
    132       publish_operation.Execute<false, tChangeStatus::CHANGED, true, true>(*this); 
     132      publish_operation.Execute<tChangeStatus::CHANGED, true, true>(*this); 
    133133    } 
    134134  } 
     
    137137    if (change_constant == tChangeStatus::CHANGED_INITIAL) 
    138138    { 
    139       publish_operation.Execute<false, tChangeStatus::CHANGED_INITIAL, true, false>(*this); 
     139      publish_operation.Execute<tChangeStatus::CHANGED_INITIAL, true, false>(*this); 
    140140    } 
    141141    else 
    142142    { 
    143       publish_operation.Execute<false, tChangeStatus::CHANGED, true, false>(*this); 
     143      publish_operation.Execute<tChangeStatus::CHANGED, true, false>(*this); 
    144144    } 
    145145  } 
     
    152152 
    153153  common::tPublishOperation<tSingleThreadedCheapCopyPortGeneric, tPublishingData> publish_operation(current_value); 
    154   publish_operation.Execute<false, tChangeStatus::CHANGED, false, false>(static_cast<tSingleThreadedCheapCopyPortGeneric&>(other)); 
     154  publish_operation.Execute<tChangeStatus::CHANGED, false, false>(static_cast<tSingleThreadedCheapCopyPortGeneric&>(other)); 
    155155} 
    156156 
     
    160160} 
    161161 
    162 void tSingleThreadedCheapCopyPortGeneric::InitialPushTo(tAbstractPort& target, bool reverse) 
     162void tSingleThreadedCheapCopyPortGeneric::InitialPushTo(core::tConnector& connector) 
    163163{ 
    164164  common::tPublishOperation<tSingleThreadedCheapCopyPortGeneric, tPublishingData> data(current_value); 
    165   tSingleThreadedCheapCopyPortGeneric& target_port = static_cast<tSingleThreadedCheapCopyPortGeneric&>(target); 
    166   if (reverse) 
    167   { 
    168     common::tPublishOperation<tSingleThreadedCheapCopyPortGeneric, tPublishingData>::Receive<true, tChangeStatus::CHANGED_INITIAL>(data, target_port, *this); 
    169   } 
    170   else 
    171   { 
    172     common::tPublishOperation<tSingleThreadedCheapCopyPortGeneric, tPublishingData>::Receive<false, tChangeStatus::CHANGED_INITIAL>(data, target_port, *this); 
    173   } 
     165  tSingleThreadedCheapCopyPortGeneric& target_port = static_cast<tSingleThreadedCheapCopyPortGeneric&>(connector.Destination()); 
     166  common::tPublishOperation<tSingleThreadedCheapCopyPortGeneric, tPublishingData>::Receive<tChangeStatus::CHANGED_INITIAL>(data, target_port, *this); 
    174167} 
    175168 
     
    186179    current_value.timestamp = timestamp; 
    187180    common::tPublishOperation<tSingleThreadedCheapCopyPortGeneric, tPublishingData> publish_operation(current_value); 
    188     publish_operation.Execute<false, tChangeStatus::CHANGED, false, false>(*this); 
     181    publish_operation.Execute<tChangeStatus::CHANGED, false, false>(*this); 
    189182  } 
    190183} 
  • optimized/tSingleThreadedCheapCopyPortGeneric.h

    r107 r114  
    294294 
    295295  virtual int GetMaxQueueLengthImplementation() const override; 
    296   virtual void InitialPushTo(tAbstractPort& target, bool reverse) override; 
     296  virtual void InitialPushTo(core::tConnector& connector) override; 
    297297 
    298298  /*! 
  • standard/tStandardPort.cpp

    r107 r114  
    179179    if (change_constant == tChangeStatus::CHANGED_INITIAL) 
    180180    { 
    181       PublishImplementation<false, tChangeStatus::CHANGED_INITIAL, true, true>(data); 
     181      PublishImplementation<tChangeStatus::CHANGED_INITIAL, true, true>(data); 
    182182    } 
    183183    else 
    184184    { 
    185       PublishImplementation<false, tChangeStatus::CHANGED, true, true>(data); 
     185      PublishImplementation<tChangeStatus::CHANGED, true, true>(data); 
    186186    } 
    187187  } 
     
    190190    if (change_constant == tChangeStatus::CHANGED_INITIAL) 
    191191    { 
    192       PublishImplementation<false, tChangeStatus::CHANGED_INITIAL, true, false>(data); 
     192      PublishImplementation<tChangeStatus::CHANGED_INITIAL, true, false>(data); 
    193193    } 
    194194    else 
    195195    { 
    196       PublishImplementation<false, tChangeStatus::CHANGED, true, false>(data); 
     196      PublishImplementation<tChangeStatus::CHANGED, true, false>(data); 
    197197    } 
    198198  } 
     
    267267} 
    268268 
    269 void tStandardPort::InitialPushTo(tAbstractPort& target, bool reverse) 
     269void tStandardPort::InitialPushTo(core::tConnector& connector) 
    270270{ 
    271271  tLockingManagerPointer manager = GetCurrentValueRaw(tStrategy::NEVER_PULL); 
     
    273273 
    274274  common::tPublishOperation<tStandardPort, tPublishingData> data(manager, 1000); 
    275   tStandardPort& target_port = static_cast<tStandardPort&>(target); 
    276   if (reverse) 
    277   { 
    278     common::tPublishOperation<tStandardPort, tPublishingData>::Receive<true, tChangeStatus::CHANGED_INITIAL>(data, target_port, *this); 
    279   } 
    280   else 
    281   { 
    282     common::tPublishOperation<tStandardPort, tPublishingData>::Receive<false, tChangeStatus::CHANGED_INITIAL>(data, target_port, *this); 
    283   } 
     275  tStandardPort& target_port = static_cast<tStandardPort&>(connector.Destination()); 
     276  common::tPublishOperation<tStandardPort, tPublishingData>::Receive<tChangeStatus::CHANGED_INITIAL>(data, target_port, *this); 
    284277} 
    285278 
  • standard/tStandardPort.h

    r107 r114  
    256256  inline void Publish(tUnusedManagerPointer& data) 
    257257  { 
    258     PublishImplementation<false, tChangeStatus::CHANGED, false, false>(data); 
     258    PublishImplementation<tChangeStatus::CHANGED, false, false>(data); 
    259259  } 
    260260  inline void Publish(tLockingManagerPointer& data) 
    261261  { 
    262     PublishImplementation<false, tChangeStatus::CHANGED, false, false>(data); 
     262    PublishImplementation<tChangeStatus::CHANGED, false, false>(data); 
    263263  } 
    264264 
     
    490490  virtual int GetMaxQueueLengthImplementation() const override; 
    491491 
    492   // quite similar to publish 
    493   virtual void InitialPushTo(tAbstractPort& target, bool reverse) override; 
     492  virtual void InitialPushTo(core::tConnector& connector) override; 
    494493 
    495494  /*! 
     
    538537   * 
    539538   * \param data Data to publish 
    540    * \param reverse Value received in reverse direction? 
    541539   * \param changed_constant changedConstant to use 
    542540   */ 
    543   inline void Publish(tUnusedManagerPointer& data, bool reverse, tChangeStatus changed_constant) 
    544   { 
    545     if (!reverse) 
    546     { 
    547       if (changed_constant == tChangeStatus::CHANGED) 
    548       { 
    549         PublishImplementation<false, tChangeStatus::CHANGED, false, false>(data); 
    550       } 
    551       else 
    552       { 
    553         PublishImplementation<false, tChangeStatus::CHANGED_INITIAL, false, false>(data); 
    554       } 
     541  inline void Publish(tUnusedManagerPointer& data, tChangeStatus changed_constant) 
     542  { 
     543    if (changed_constant == tChangeStatus::CHANGED) 
     544    { 
     545      PublishImplementation<tChangeStatus::CHANGED, false, false>(data); 
    555546    } 
    556547    else 
    557548    { 
    558       if (changed_constant == tChangeStatus::CHANGED) 
    559       { 
    560         PublishImplementation<true, tChangeStatus::CHANGED, false, false>(data); 
    561       } 
    562       else 
    563       { 
    564         PublishImplementation<true, tChangeStatus::CHANGED_INITIAL, false, false>(data); 
    565       } 
     549      PublishImplementation<tChangeStatus::CHANGED_INITIAL, false, false>(data); 
    566550    } 
    567551  } 
     
    575559   * 
    576560   * \param data Data buffer 
    577    * \tparam REVERSE Publish in reverse direction? (typical is forward) 
    578561   * \tparam CHANGE_CONSTANT changedConstant to use 
    579562   * \tparam BROWSER_PUBLISH Inform this port's listeners on change and also publish in reverse direction? (only set from BrowserPublish()) 
    580563   */ 
    581   template <bool REVERSE, tChangeStatus CHANGE_CONSTANT, bool BROWSER_PUBLISH, bool NOTIFY_LISTENER_ON_THIS_PORT, typename TDeleter> 
     564  template <tChangeStatus CHANGE_CONSTANT, bool BROWSER_PUBLISH, bool NOTIFY_LISTENER_ON_THIS_PORT, typename TDeleter> 
    582565  inline void PublishImplementation(std::unique_ptr<tPortBufferManager, TDeleter>& data) 
    583566  { 
     
    589572 
    590573    common::tPublishOperation<tStandardPort, tPublishingData> publish_operation(data, 1000); 
    591     publish_operation.Execute<REVERSE, CHANGE_CONSTANT, BROWSER_PUBLISH, NOTIFY_LISTENER_ON_THIS_PORT>(*this); 
     574    publish_operation.Execute<CHANGE_CONSTANT, BROWSER_PUBLISH, NOTIFY_LISTENER_ON_THIS_PORT>(*this); 
    592575  } 
    593576 
  • tests/initial_pushing.cpp

    r106 r114  
    9797  tOutputPort<T> output_port("Output Port", parent); 
    9898  tInputPort<T> input_port("Input Port", parent); 
    99   tOutputPort<T> output_port_reverse("Output Port with reverse pushing", core::tFrameworkElement::tFlag::PUSH_STRATEGY_REVERSE, parent); 
     99  tOutputPort<T> output_port_2("Another output port", parent); 
    100100  core::tFrameworkElement::InitAll(); 
    101101 
     
    105105  // Connect to other ports and check their values 
    106106  output_port.ConnectTo(input_port); 
    107   output_port_reverse.ConnectTo(input_port); 
     107  output_port_2.ConnectTo(input_port); 
    108108  CheckPortValue(input_port, test_values[0]); 
    109   CheckPortValue(output_port_reverse, test_values[0]); 
    110109 
    111110  // Change strategy and see if everything behaves as expected 
     
    114113  input_port.SetPushStrategy(true); 
    115114  CheckPortValue(input_port, test_values[0]); // expects old value because we have two sources => no push 
    116   CheckPortValue(output_port_reverse, test_values[0]); 
    117   output_port_reverse.SetReversePushStrategy(false); 
    118115  output_port.Publish(test_values[2]); 
    119   CheckPortValue(output_port_reverse, test_values[0]); 
    120   output_port_reverse.SetReversePushStrategy(true); 
    121   CheckPortValue(output_port_reverse, test_values[2]); 
    122116 
    123117  // now for a complex net 
Note: See TracChangeset for help on using the changeset viewer.