Changeset 2:0e4ebe0a4b20 in rrlib_buffer_pools


Ignore:
Timestamp:
21.10.2012 15:57:13 (7 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Adapted to changes in rrlib_concurrent_containers.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • policies/management/ArrayAndFlagBased.h

    r1 r2  
    7575 */ 
    7676template < typename T, 
    77          concurrent_containers::tQueueConcurrency CONCURRENCY, 
    78          typename TAddMutex = typename std::conditional < (CONCURRENCY == concurrent_containers::tQueueConcurrency::FULL_FAST) || (CONCURRENCY == concurrent_containers::tQueueConcurrency::MULTIPLE_READERS_FAST), thread::tMutex, thread::tNoMutex >::type > 
     77         concurrent_containers::tConcurrency CONCURRENCY, 
     78         typename TAddMutex = typename std::conditional < (CONCURRENCY == concurrent_containers::tConcurrency::FULL) || (CONCURRENCY == concurrent_containers::tConcurrency::MULTIPLE_READERS), thread::tMutex, thread::tNoMutex >::type > 
    7979class ArrayAndFlagBased : TAddMutex 
    8080{ 
    81   enum { cMULTIPLE_READERS = (CONCURRENCY == concurrent_containers::tQueueConcurrency::FULL_FAST) || (CONCURRENCY == concurrent_containers::tQueueConcurrency::MULTIPLE_READERS_FAST) }; 
    82   enum { cATOMIC_ARRAY_ELEMENTS = (CONCURRENCY != concurrent_containers::tQueueConcurrency::NONE) }; 
     81  enum { cMULTIPLE_READERS = (CONCURRENCY == concurrent_containers::tConcurrency::FULL) || (CONCURRENCY == concurrent_containers::tConcurrency::MULTIPLE_READERS) }; 
     82  enum { cATOMIC_ARRAY_ELEMENTS = (CONCURRENCY != concurrent_containers::tConcurrency::NONE) }; 
    8383  enum { cARRAY_CHUNK_SIZE = 15 }; // TODO make this template argument 
    8484  typedef typename std::conditional<cATOMIC_ARRAY_ELEMENTS, std::atomic<T*>, T*>::type tArrayElement; 
  • policies/management/QueueBased.h

    r0 r2  
    7070 * Con: Types T must be queueable => memory overhead & possibly difficult to achieve 
    7171 */ 
    72 template <typename T, concurrent_containers::tQueueConcurrency CONCURRENCY> 
     72template <typename T, concurrent_containers::tConcurrency CONCURRENCY> 
    7373class QueueBased 
    7474{ 
    7575 
    76   static_assert(std::is_base_of<concurrent_containers::tQueueable, T>::value || 
    77                 (CONCURRENCY == concurrent_containers::tQueueConcurrency::NONE && std::is_base_of<concurrent_containers::tQueueableSingleThreaded, T>::value), 
     76  static_assert(std::is_base_of<concurrent_containers::queue::tQueueableMost, T>::value || 
     77                (CONCURRENCY == concurrent_containers::tConcurrency::NONE && std::is_base_of<concurrent_containers::queue::tQueueableSingleThreaded, T>::value), 
    7878                "Only queueable types may be used with queue-based policy. Choosing UseBufferContainer Recycling policy might be an alternative."); 
     79 
     80  /*! Pointer type used in internal queue (we don't want any auto-recycling here) */ 
     81  typedef std::unique_ptr<T> tQueuePointer; 
     82 
     83  /*! 
     84   * Type of queue backend. 
     85   * TODO: maybe we should make dequeue mode choosable. 
     86   * Using fast queue implementation will reduce computational overhead. 
     87   * On the other hand there is always one additional unused buffer in pool. 
     88   */ 
     89  typedef concurrent_containers::tQueue<tQueuePointer, CONCURRENCY, concurrent_containers::tDequeueMode::FIFO_FAST> tQueueType; 
    7990 
    8091//---------------------------------------------------------------------- 
     
    109120      buffer_count--; 
    110121    } 
    111     return buffer_count - concurrent_containers::tQueue<tQueuePointer, CONCURRENCY>::cMINIMUM_ELEMENTS_IN_QEUEUE; 
     122    return buffer_count - tQueueType::cMINIMUM_ELEMENTS_IN_QEUEUE; 
    112123  } 
    113124 
     
    130141private: 
    131142 
    132   /*! Pointer type used in internal queue (we don't want any auto-recycling here) */ 
    133   typedef std::unique_ptr<T> tQueuePointer; 
    134  
    135143  /*! Queue containing the unused buffers of this pool */ 
    136   concurrent_containers::tQueue<tQueuePointer, CONCURRENCY> unused_buffers; 
     144  tQueueType unused_buffers; 
    137145 
    138146  /*! Number of buffers in this pool */ 
  • tBufferContainer.h

    r0 r2  
    6868 */ 
    6969template <typename T> 
    70 class tBufferContainer : public tBufferManagementInfo, public rrlib::concurrent_containers::tQueueable 
     70class tBufferContainer : public tBufferManagementInfo, public concurrent_containers::tQueueable<concurrent_containers::tQueueability::MOST_OPTIMIZED> 
    7171{ 
    7272 
  • tBufferManagementInfo.h

    r0 r2  
    4141// External includes (system with <>, local with "") 
    4242//---------------------------------------------------------------------- 
     43#include "rrlib/concurrent_containers/tConcurrency.h" 
    4344 
    4445//---------------------------------------------------------------------- 
     
    6061namespace management 
    6162{ 
    62 template <typename T, concurrent_containers::tQueueConcurrency CONCURRENCY, typename> 
     63template <typename T, concurrent_containers::tConcurrency CONCURRENCY, typename> 
    6364class ArrayAndFlagBased; 
    6465 
    65 template <typename T, concurrent_containers::tQueueConcurrency CONCURRENCY> 
     66template <typename T, concurrent_containers::tConcurrency CONCURRENCY> 
    6667class QueueBased; 
    6768} 
     
    9192private: 
    9293 
    93   template <typename T, concurrent_containers::tQueueConcurrency CONCURRENCY, typename> 
     94  template <typename T, concurrent_containers::tConcurrency CONCURRENCY, typename> 
    9495  friend class management::ArrayAndFlagBased; 
    9596 
    96   template <typename T, concurrent_containers::tQueueConcurrency CONCURRENCY> 
     97  template <typename T, concurrent_containers::tConcurrency CONCURRENCY> 
    9798  friend class management::QueueBased; 
    9899 
  • tBufferPool.h

    r0 r2  
    9999 */ 
    100100template < typename T, 
    101          concurrent_containers::tQueueConcurrency CONCURRENCY, 
    102          template <typename, concurrent_containers::tQueueConcurrency, typename ...> class TBufferManagementPolicy = management::QueueBased, 
     101         concurrent_containers::tConcurrency CONCURRENCY, 
     102         template <typename, concurrent_containers::tConcurrency, typename ...> class TBufferManagementPolicy = management::QueueBased, 
    103103         template <typename> class TDeletingPolicy = deleting::ComplainOnMissingBuffers, 
    104104         template <typename, typename> class TRecycling = recycling::StoreOwnerInUniquePointer, 
  • test/basic_operation.cpp

    r0 r2  
    6161// Implementation 
    6262//---------------------------------------------------------------------- 
    63 class tTestType : public tQueueable, public tBufferManagementInfo 
     63class tTestType : public tQueueable<tQueueability::MOST_OPTIMIZED>, public tBufferManagementInfo 
    6464{ 
    6565public: 
     
    126126template < typename T, 
    127127         bool INSTANT_DELETE, 
    128          template <typename, tQueueConcurrency, typename ...> class TBufferManagementPolicy, 
     128         template <typename, tConcurrency, typename ...> class TBufferManagementPolicy, 
    129129         template <typename> class TDeletingPolicy, 
    130130         template <typename, typename> class TRecycling, 
     
    134134  RRLIB_LOG_PRINTF(USER, " "); 
    135135  { 
    136     RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tQueueConcurrency::NONE"); 
    137     typedef tBufferPool<T, tQueueConcurrency::NONE, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
     136    RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tConcurrency::NONE"); 
     137    typedef tBufferPool<T, tConcurrency::NONE, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
    138138    TestBufferPool<T, typename tPool::tManagedType, INSTANT_DELETE>(new tPool()); 
    139139  } 
    140140  { 
    141     RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tQueueConcurrency::SINGLE_READER_AND_WRITER_FAST"); 
    142     typedef tBufferPool<T, tQueueConcurrency::SINGLE_READER_AND_WRITER_FAST, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
     141    RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tConcurrency::SINGLE_READER_AND_WRITER"); 
     142    typedef tBufferPool<T, tConcurrency::SINGLE_READER_AND_WRITER, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
    143143    TestBufferPool<T, typename tPool::tManagedType, INSTANT_DELETE>(new tPool()); 
    144144  } 
    145145  { 
    146     RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tQueueConcurrency::MULTIPLE_WRITERS"); 
    147     typedef tBufferPool<T, tQueueConcurrency::MULTIPLE_WRITERS, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
     146    RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tConcurrency::MULTIPLE_WRITERS"); 
     147    typedef tBufferPool<T, tConcurrency::MULTIPLE_WRITERS, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
    148148    TestBufferPool<T, typename tPool::tManagedType, INSTANT_DELETE>(new tPool()); 
    149149  } 
    150150  { 
    151     RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tQueueConcurrency::MULTIPLE_WRITERS_FAST"); 
    152     typedef tBufferPool<T, tQueueConcurrency::MULTIPLE_WRITERS_FAST, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
     151    RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tConcurrency::MULTIPLE_READERS"); 
     152    typedef tBufferPool<T, tConcurrency::MULTIPLE_READERS, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
    153153    TestBufferPool<T, typename tPool::tManagedType, INSTANT_DELETE>(new tPool()); 
    154154  } 
    155155  { 
    156     RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tQueueConcurrency::MULTIPLE_READERS_FAST"); 
    157     typedef tBufferPool<T, tQueueConcurrency::MULTIPLE_READERS_FAST, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
    158     TestBufferPool<T, typename tPool::tManagedType, INSTANT_DELETE>(new tPool()); 
    159   } 
    160   { 
    161     RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tQueueConcurrency::FULL_FAST"); 
    162     typedef tBufferPool<T, tQueueConcurrency::FULL_FAST, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
     156    RRLIB_LOG_PRINTF(USER, pool_type_printf_string, "tConcurrency::FULL"); 
     157    typedef tBufferPool<T, tConcurrency::FULL, TBufferManagementPolicy, TDeletingPolicy, TRecycling, TBufferManagementPolicyArgs...> tPool; 
    163158    TestBufferPool<T, typename tPool::tManagedType, INSTANT_DELETE>(new tPool()); 
    164159  } 
Note: See TracChangeset for help on using the changeset viewer.