1 /* 2 * Copyright (c) 2014, 2015, Dynatrace and/or its affiliates. All rights reserved. 3 * 4 * This file is part of the Lock Contention Tracing Subsystem for the HotSpot 5 * Virtual Machine, which is developed at Christian Doppler Laboratory on 6 * Monitoring and Evolution of Very-Large-Scale Software Systems. Please 7 * contact us at <http://mevss.jku.at/> if you need additional information 8 * or have any questions. 9 * 10 * This code is free software; you can redistribute it and/or modify it 11 * under the terms of the GNU General Public License version 2 only, as 12 * published by the Free Software Foundation. 13 * 14 * This code is distributed in the hope that it will be useful, but WITHOUT 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 * version 2 for more details (a copy is included in the LICENSE file that 18 * accompanied this code). 19 * 20 * You should have received a copy of the GNU General Public License version 21 * 2 along with this work. If not, see <http://www.gnu.org/licenses/>. 22 * 23 */ 24 25 #ifndef SHARE_VM_EVTRACE_TRACEBUFFERQUEUE_HPP 26 #define SHARE_VM_EVTRACE_TRACEBUFFERQUEUE_HPP 27 28 #include "memory/allocation.hpp" 29 30 class TraceBuffer; 31 32 class TraceBufferQueue: public CHeapObj<mtEventTracing> { 33 private: 34 volatile jlong _enqueue_ops; 35 volatile jlong _dequeue_ops; 36 volatile int _mtx; 37 TraceBuffer * volatile _head; 38 TraceBuffer * volatile _tail; 39 40 class SpinLocker; 41 42 public: 43 TraceBufferQueue(); 44 virtual ~TraceBufferQueue(); 45 46 bool is_empty() { return (_head == NULL); } 47 size_t count(); 48 49 void enqueue(TraceBuffer *buffer); 50 TraceBuffer * try_dequeue(); 51 52 jlong fill_mark() { return _dequeue_ops; } 53 bool has_dequeued_at_mark(jlong mark) { return (_dequeue_ops >= mark); } 54 55 jlong enqueue_ops() { return _enqueue_ops; } 56 jlong dequeue_ops() { return _dequeue_ops; } 57 }; 58 59 #endif /* SHARE_VM_EVTRACE_TRACEBUFFERQUEUE_HPP */