< prev index next >

src/hotspot/share/utilities/concurrentHashTable.hpp

Print this page

393   };
394 
395   // Check for dead items in this table with range. During shrink/grow we cannot
396   // guarantee that we only visit nodes once. To keep it simple caller will
397   // have locked _resize_lock.
398   template <typename EVALUATE_FUNC, typename DELETE_FUNC>
399   void do_bulk_delete_locked_for(Thread* thread, size_t start_idx,
400                                  size_t stop_idx, EVALUATE_FUNC& eval_f,
401                                  DELETE_FUNC& del_f, bool is_mt = false);
402 
403   // Method to delete one items.
404   template <typename LOOKUP_FUNC>
405   void delete_in_bucket(Thread* thread, Bucket* bucket, LOOKUP_FUNC& lookup_f);
406 
407  public:
408   // Default sizes
409   static const size_t DEFAULT_MAX_SIZE_LOG2 = 21;
410   static const size_t DEFAULT_START_SIZE_LOG2 = 13;
411   static const size_t DEFAULT_GROW_HINT = 4; // Chain length
412   static const bool DEFAULT_ENABLE_STATISTICS = false;

413   ConcurrentHashTable(size_t log2size = DEFAULT_START_SIZE_LOG2,
414                       size_t log2size_limit = DEFAULT_MAX_SIZE_LOG2,
415                       size_t grow_hint = DEFAULT_GROW_HINT,
416                       bool enable_statistics = DEFAULT_ENABLE_STATISTICS,
417                       Mutex::Rank rank = Mutex::nosafepoint-2,
418                       void* context = nullptr);
419 
420   explicit ConcurrentHashTable(Mutex::Rank rank, void* context, size_t log2size = DEFAULT_START_SIZE_LOG2, bool enable_statistics = DEFAULT_ENABLE_STATISTICS) :
421     ConcurrentHashTable(log2size, DEFAULT_MAX_SIZE_LOG2, DEFAULT_GROW_HINT, enable_statistics, rank, context) {}
422 
423   ~ConcurrentHashTable();
424 
425   size_t get_mem_size(Thread* thread);
426 
427   size_t get_size_log2(Thread* thread);
428   static size_t get_node_size() { return sizeof(Node); }
429   static size_t get_dynamic_node_size(size_t value_size);
430   bool is_max_size_reached() { return _size_limit_reached; }
431 
432   // This means no paused bucket resize operation is going to resume
433   // on this table.
434   bool is_safepoint_safe() { return _resize_lock_owner == nullptr; }
435 
436   // Re-size operations.
437   bool shrink(Thread* thread, size_t size_limit_log2 = 0);

393   };
394 
395   // Check for dead items in this table with range. During shrink/grow we cannot
396   // guarantee that we only visit nodes once. To keep it simple caller will
397   // have locked _resize_lock.
398   template <typename EVALUATE_FUNC, typename DELETE_FUNC>
399   void do_bulk_delete_locked_for(Thread* thread, size_t start_idx,
400                                  size_t stop_idx, EVALUATE_FUNC& eval_f,
401                                  DELETE_FUNC& del_f, bool is_mt = false);
402 
403   // Method to delete one items.
404   template <typename LOOKUP_FUNC>
405   void delete_in_bucket(Thread* thread, Bucket* bucket, LOOKUP_FUNC& lookup_f);
406 
407  public:
408   // Default sizes
409   static const size_t DEFAULT_MAX_SIZE_LOG2 = 21;
410   static const size_t DEFAULT_START_SIZE_LOG2 = 13;
411   static const size_t DEFAULT_GROW_HINT = 4; // Chain length
412   static const bool DEFAULT_ENABLE_STATISTICS = false;
413   static const Mutex::Rank DEFAULT_MUTEX_RANK = static_cast<Mutex::Rank>(static_cast<int>(Mutex::nosafepoint) - 2);
414   ConcurrentHashTable(size_t log2size = DEFAULT_START_SIZE_LOG2,
415                       size_t log2size_limit = DEFAULT_MAX_SIZE_LOG2,
416                       size_t grow_hint = DEFAULT_GROW_HINT,
417                       bool enable_statistics = DEFAULT_ENABLE_STATISTICS,
418                       Mutex::Rank rank = DEFAULT_MUTEX_RANK,
419                       void* context = nullptr);
420 
421   explicit ConcurrentHashTable(Mutex::Rank rank, void* context, size_t log2size = DEFAULT_START_SIZE_LOG2, bool enable_statistics = DEFAULT_ENABLE_STATISTICS) :
422     ConcurrentHashTable(log2size, DEFAULT_MAX_SIZE_LOG2, DEFAULT_GROW_HINT, enable_statistics, rank, context) {}
423 
424   ~ConcurrentHashTable();
425 
426   size_t get_mem_size(Thread* thread);
427 
428   size_t get_size_log2(Thread* thread);
429   static size_t get_node_size() { return sizeof(Node); }
430   static size_t get_dynamic_node_size(size_t value_size);
431   bool is_max_size_reached() { return _size_limit_reached; }
432 
433   // This means no paused bucket resize operation is going to resume
434   // on this table.
435   bool is_safepoint_safe() { return _resize_lock_owner == nullptr; }
436 
437   // Re-size operations.
438   bool shrink(Thread* thread, size_t size_limit_log2 = 0);
< prev index next >