1 /* 2 * Copyright (c) 2012, 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_RECORDER_STORAGE_JFRSTORAGECONTROL_HPP 26 #define SHARE_VM_JFR_RECORDER_STORAGE_JFRSTORAGECONTROL_HPP 27 28 #include "jfr/utilities/jfrAllocation.hpp" 29 30 class JfrStorageControl : public JfrCHeapObj { 31 private: 32 size_t _global_count_total; 33 size_t _full_count; 34 volatile size_t _global_lease_count; 35 volatile size_t _dead_count; 36 size_t _to_disk_threshold; 37 size_t _in_memory_discard_threshold; 38 size_t _global_lease_threshold; 39 size_t _scavenge_threshold; 40 bool _to_disk; 41 42 public: 43 JfrStorageControl(size_t global_count_total, size_t in_memory_discard_threshold); 44 45 void set_to_disk(bool enable); 46 bool to_disk() const; 47 48 size_t full_count() const; 49 size_t increment_full(); 50 size_t decrement_full(); 51 void reset_full(); 52 bool should_post_buffer_full_message() const; 53 bool should_discard() const; 54 55 size_t global_lease_count() const; 56 size_t increment_leased(); 57 size_t decrement_leased(); 58 bool is_global_lease_allowed() const; 59 60 size_t dead_count() const; 61 size_t increment_dead(); 62 size_t decrement_dead(); 63 64 void set_scavenge_threshold(size_t number_of_dead_buffers); 65 bool should_scavenge() const; 66 }; 67 68 #endif // SHARE_VM_JFR_RECORDER_STORAGE_JFRSTORAGECONTROL_HPP