Changeset 130:668883069ce7 in finroc_plugins_data_ports


Ignore:
Timestamp:
01.10.2017 21:48:49 (2 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adds parameter tPortBufferPool::GetUnusedBuffer to define whether to create buffer if none is available

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/tPortBufferPool.h

    r123 r130  
    157157  /*! 
    158158   * \param data_type Data type of desired buffer 
     159   * \param possibly_create_buffer Create new buffer if there is none in pool at the moment? 
    159160   * \return Returns unused buffer. If there are no buffers that can be reused, a new buffer is allocated. 
    160161   */ 
    161162  template <bool Tstandard_port = cSTANDARD_PORT> 
    162   inline tPointer GetUnusedBuffer(const typename std::enable_if<Tstandard_port, rrlib::rtti::tType>::type& data_type) 
     163  inline tPointer GetUnusedBuffer(const typename std::enable_if<Tstandard_port, rrlib::rtti::tType>::type& data_type, bool possibly_create_buffer = true) 
    163164  { 
    164165    tPointer buffer = buffer_pool.GetUnusedBuffer(); 
     
    167168      return std::move(buffer); 
    168169    } 
    169     return CreateBuffer(data_type); 
     170    return possibly_create_buffer ? CreateBuffer(data_type) : tPointer(); 
    170171  } 
    171172 
Note: See TracChangeset for help on using the changeset viewer.