src/hotspot/share/jfr/leakprofiler/sampling/sampleList.hpp
changeset 50113 caf115bb98ad
child 52850 f527b24990d7
equal deleted inserted replaced
50112:7a2a740815b7 50113:caf115bb98ad
       
     1 /*
       
     2  * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 #ifndef SHARE_VM_JFR_LEAKPROFILER_SAMPLING_SAMPLELIST_HPP
       
    26 #define SHARE_VM_JFR_LEAKPROFILER_SAMPLING_SAMPLELIST_HPP
       
    27 #include "jfr/utilities/jfrAllocation.hpp"
       
    28 #include "jfr/utilities/jfrDoublyLinkedList.hpp"
       
    29 
       
    30 class ObjectSample;
       
    31 
       
    32 class SampleList : public JfrCHeapObj {
       
    33   typedef JfrDoublyLinkedList<ObjectSample> List;
       
    34  private:
       
    35   List _free_list;
       
    36   List _in_use_list;
       
    37   const ObjectSample* _last_resolved;
       
    38   mutable size_t _allocated;
       
    39   const size_t _limit;
       
    40   const size_t _cache_size;
       
    41 
       
    42   void populate_cache();
       
    43   ObjectSample* newSample() const;
       
    44   void link(ObjectSample* sample);
       
    45   void unlink(ObjectSample* sample);
       
    46   void deallocate_samples(List& list);
       
    47   void reset(ObjectSample* sample);
       
    48 
       
    49  public:
       
    50   SampleList(size_t limit, size_t cache_size = 0);
       
    51   ~SampleList();
       
    52 
       
    53   void set_last_resolved(const ObjectSample* sample);
       
    54   ObjectSample* get();
       
    55   ObjectSample* last() const;
       
    56   void release(ObjectSample* sample);
       
    57   const ObjectSample* last_resolved() const;
       
    58   ObjectSample* reuse(ObjectSample* sample);
       
    59   bool is_full() const;
       
    60   size_t count() const;
       
    61 };
       
    62 
       
    63 #endif // SHARE_VM_JFR_LEAKPROFILER_SAMPLING_SAMPLELIST_HPP