STLdb

PrevUpHomeNext

Class template trans_map

stldb::concurrent::trans_map — Parameters:.

Synopsis

// In header: </Users/bobw/workspace/stldb_lib/stldb/containers/concurrent_trans_map.h>

template<typename K, typename V, typename Comparator = std::less<K>, 
         typename Allocator = boost::interprocess::allocator<std::pair<const K, V>,						    typename boost::interprocess::managed_mapped_file::segment_manager>, 
         typename mutex_family = stldb::bounded_mutex_family, 
         int picket_lock_size = 31> 
class trans_map {
public:
  // types
  typedef Allocator::template rebind< std::pair< K, TransEntry< V > > >::other                                                  base_alloc;            
  typedef boost::interprocess::map< K, TransEntry< V >, Comparator, base_alloc >                                                baseclass;             
  typedef K                                                                                                                     key_type;              
  typedef TransEntry< V >                                                                                                       mapped_type;           
  typedef std::pair< const K, TransEntry< V > >                                                                                 value_type;            
  typedef Comparator                                                                                                            key_compare;           
  typedef Allocator                                                                                                             allocator_type;        
  typedef mutex_family::upgradable_mutex_type                                                                                   upgradable_mutex_type; 
  typedef mutex_family::mutex_type                                                                                              mutex_type;            
  typedef mutex_family::condition_type                                                                                          condition_type;        
  typedef picket_lock_set< value_type, mutex_type, picket_lock_size >                                                           picket_lock_t;         
  typedef value_type &                                                                                                          reference;             
  typedef const value_type &                                                                                                    const_reference;       
  typedef value_type *                                                                                                          pointer;               
  typedef const value_type *                                                                                                    const_pointer;         
  typedef Allocator::size_type                                                                                                  size_type;             
  typedef Allocator::difference_type                                                                                            difference_type;       
  typedef trans_assoc_iterator< trans_map, typename baseclass::iterator, boost::interprocess::scoped_lock< mutex_type > >       iterator;              
  typedef trans_assoc_iterator< trans_map, typename baseclass::const_iterator, boost::interprocess::scoped_lock< mutex_type > > const_iterator;        
  typedef std::reverse_iterator< iterator >                                                                                     reverse_iterator;      
  typedef std::reverse_iterator< const_iterator >                                                                               const_reverse_iterator;

  // member classes/structs/unions

  struct pending_change_map_t {
    // construct/copy/destruct
    pending_change_map_t();
    bool exclusive_commit;
    bool exclusive_rollback;
    std::vector< typename trans_map::pointer > _modified_entries;
    std::vector< mutex_type * > _locks_held;
  };

  struct trans_map_op_factory {

    // public member functions
    TransactionalOperation * create(TransactionalOperations, trans_map &) ;
  };

  // construct/copy/destruct
  trans_map(const Comparator &, const Allocator &, const char *);
  template<typename InputIterator> 
    trans_map(InputIterator, InputIterator, const Comparator &, 
              const Allocator &, const Transaction &, int);
  trans_map(const trans_map &);
  ~trans_map();

  // public member functions
  allocator_type get_allocator() const;
  iterator begin() ;
  const_iterator begin() const;
  iterator end() ;
  const_iterator end() const;
  reverse_iterator rbegin() ;
  const_reverse_iterator rbegin() const;
  reverse_iterator rend() ;
  const_reverse_iterator rend() const;
  iterator begin(Transaction &) ;
  iterator end(Transaction &) ;
  reverse_iterator rbegin(Transaction &) ;
  reverse_iterator rend(Transaction &) ;
  std::pair< iterator, bool > insert(const value_type &, Transaction &) ;
  iterator insert(iterator, const value_type &, Transaction &) ;
  template<typename InputIterator> 
    void insert(InputIterator, InputIterator, Transaction &) ;
  template<typename wait_policy_t> 
    std::pair< iterator, bool > 
    insert(const value_type &, Transaction &, wait_policy_t &) ;
  template<typename wait_policy_t> 
    iterator insert(iterator, const value_type &, Transaction &, 
                    wait_policy_t &) ;
  template<typename InputIterator, typename wait_policy_t> 
    void insert(InputIterator, InputIterator, Transaction &, wait_policy_t &) ;
  void erase(iterator, Transaction &) ;
  size_type erase(const K &, Transaction &) ;
  void erase(iterator, iterator, Transaction &) ;
  template<typename wait_policy_t> 
    void erase(iterator, Transaction &, wait_policy_t &) ;
  template<typename wait_policy_t> 
    size_type erase(const K &, Transaction &, wait_policy_t &) ;
  template<typename wait_policy_t> 
    void erase(iterator, iterator, Transaction &, wait_policy_t &) ;
  void clear(exclusive_transaction &) ;
  void swap(trans_map &, exclusive_transaction &) ;
  iterator find(const K &) ;
  const_iterator find(const K &) const;
  iterator find(const K &, Transaction &) ;
  iterator lower_bound(const K &) ;
  const_iterator lower_bound(const K &) const;
  iterator lower_bound(const K &, Transaction &) ;
  iterator upper_bound(const K &) ;
  const_iterator upper_bound(const K &) const;
  iterator upper_bound(const K &, Transaction &) ;
  void lock(iterator &, Transaction &) ;
  template<typename wait_policy_t> 
    void lock(iterator &, Transaction &, wait_policy_t &) ;
  V & update(iterator &, const V &, Transaction &) ;
  template<typename wait_policy_t> 
    V & update(iterator &, const V &, Transaction &, wait_policy_t &) ;
  upgradable_mutex_type & mutex() ;
  mutex_type & mutexForRow(const typename baseclass::iterator &) ;
  void print_stats() ;
  const char * get_name() ;

  // private member functions
  template<typename bound_method_t, typename wait_policy_t> 
    bound_method_t::result_type 
    while_row_locked(const bound_method_t &, iterator &, Transaction &, 
                     wait_policy_t &) ;
  void erase_i(iterator &, Transaction &) ;
  baseclass::size_type erase_i(const K &, Transaction &) ;
  void erase_i(iterator &, iterator, Transaction &) ;
  void lock_i(iterator &, Transaction &) ;
  V & update_i(iterator &, const V &, Transaction &) ;
  value_type & pendingUpdate(Transaction &, typename baseclass::iterator) ;
  value_type addPendingUpdate(Transaction &, typename baseclass::iterator, 
                              const V &) ;
  void addPendingInsert(Transaction &, typename baseclass::iterator) ;
  void addPendingErase(Transaction &, typename baseclass::iterator) ;
  void addPendingUnlock(Transaction &, typename baseclass::iterator) ;
  void save_checkpoint(std::ostream &) ;
  void load_checkpoint(std::istream &) ;
};

Description

trans_map public construct/copy/destruct

  1. trans_map(const Comparator & comp, const Allocator & alloc, const char * name);
  2. template<typename InputIterator> 
      trans_map(InputIterator first, InputIterator last, const Comparator & comp, 
                const Allocator & alloc, const Transaction & trans, int id);
  3. trans_map(const trans_map & rarg);
  4. ~trans_map();

trans_map public member functions

  1. allocator_type get_allocator() const;
  2. iterator begin() ;
  3. const_iterator begin() const;
  4. iterator end() ;
  5. const_iterator end() const;
  6. reverse_iterator rbegin() ;
  7. const_reverse_iterator rbegin() const;
  8. reverse_iterator rend() ;
  9. const_reverse_iterator rend() const;
  10. iterator begin(Transaction & trans) ;
  11. iterator end(Transaction & trans) ;
  12. reverse_iterator rbegin(Transaction & trans) ;
  13. reverse_iterator rend(Transaction & trans) ;
  14. std::pair< iterator, bool > insert(const value_type &, Transaction & trans) ;
  15. iterator insert(iterator, const value_type &, Transaction & trans) ;
  16. template<typename InputIterator> 
      void insert(InputIterator, InputIterator, Transaction & trans) ;
  17. template<typename wait_policy_t> 
      std::pair< iterator, bool > 
      insert(const value_type &, Transaction & trans, wait_policy_t & wait_policy) ;
  18. template<typename wait_policy_t> 
      iterator insert(iterator, const value_type &, Transaction & trans, 
                      wait_policy_t & wait_policy) ;
  19. template<typename InputIterator, typename wait_policy_t> 
      void insert(InputIterator, InputIterator, Transaction & trans, 
                  wait_policy_t & wait_policy) ;
  20. void erase(iterator, Transaction & trans) ;
  21. size_type erase(const K &, Transaction & trans) ;
  22. void erase(iterator, iterator, Transaction & trans) ;
  23. template<typename wait_policy_t> 
      void erase(iterator, Transaction & trans, wait_policy_t & wait_policy) ;
  24. template<typename wait_policy_t> 
      size_type erase(const K &, Transaction & trans, wait_policy_t & wait_policy) ;
  25. template<typename wait_policy_t> 
      void erase(iterator, iterator, Transaction & trans, 
                 wait_policy_t & wait_policy) ;
  26. void clear(exclusive_transaction & trans) ;
  27. void swap(trans_map & other, exclusive_transaction & trans) ;
  28. iterator find(const K & key) ;
  29. const_iterator find(const K & key) const;
  30. iterator find(const K & key, Transaction & trans) ;
  31. iterator lower_bound(const K & key) ;
  32. const_iterator lower_bound(const K & key) const;
  33. iterator lower_bound(const K & key, Transaction & trans) ;
  34. iterator upper_bound(const K & key) ;
  35. const_iterator upper_bound(const K & key) const;
  36. iterator upper_bound(const K & key, Transaction & trans) ;
  37. void lock(iterator & i, Transaction & trans) ;
  38. template<typename wait_policy_t> 
      void lock(iterator & i, Transaction & trans, wait_policy_t & wait_policy) ;
  39. V & update(iterator & i, const V & newVal, Transaction & trans) ;
  40. template<typename wait_policy_t> 
      V & update(iterator & i, const V & newVal, Transaction & trans, 
                 wait_policy_t & wait_policy) ;
  41. upgradable_mutex_type & mutex() ;
  42. mutex_type & mutexForRow(const typename baseclass::iterator & i) ;
  43. void print_stats() ;
  44. const char * get_name() ;

trans_map private member functions

  1. template<typename bound_method_t, typename wait_policy_t> 
      bound_method_t::result_type 
      while_row_locked(const bound_method_t & bound_method, iterator & i, 
                       Transaction & trans, wait_policy_t & wait_policy) ;
  2. void erase_i(iterator & i, Transaction & trans) ;
  3. baseclass::size_type erase_i(const K &, Transaction & trans) ;
  4. void erase_i(iterator & i, iterator, Transaction & trans) ;
  5. void lock_i(iterator & i, Transaction & trans) ;
  6. V & update_i(iterator & i, const V & newVal, Transaction & trans) ;
  7. value_type & 
    pendingUpdate(Transaction & trans, typename baseclass::iterator location) ;

    Support for MVCC

  8. value_type addPendingUpdate(Transaction & trans, 
                                typename baseclass::iterator location, 
                                const V & newVal) ;
  9. void addPendingInsert(Transaction & trans, 
                          typename baseclass::iterator location) ;
  10. void addPendingErase(Transaction & trans, 
                         typename baseclass::iterator location) ;
  11. void addPendingUnlock(Transaction & trans, 
                          typename baseclass::iterator location) ;
  12. void save_checkpoint(std::ostream & out) ;
  13. void load_checkpoint(std::istream & in) ;

PrevUpHomeNext