/*
* Copyright (c) 2014, 2015, Dynatrace and/or its affiliates. All rights reserved.
*
* This file is part of the Lock Contention Tracing Subsystem for the HotSpot
* Virtual Machine, which is developed at Christian Doppler Laboratory on
* Monitoring and Evolution of Very-Large-Scale Software Systems. Please
* contact us at if you need additional information
* or have any questions.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work. If not, see .
*
*/
#ifndef SHARE_VM_EVTRACE_TRACEBUFFERQUEUE_HPP
#define SHARE_VM_EVTRACE_TRACEBUFFERQUEUE_HPP
#include "memory/allocation.hpp"
class TraceBuffer;
class TraceBufferQueue: public CHeapObj {
private:
volatile jlong _enqueue_ops;
volatile jlong _dequeue_ops;
volatile int _mtx;
TraceBuffer * volatile _head;
TraceBuffer * volatile _tail;
class SpinLocker;
public:
TraceBufferQueue();
virtual ~TraceBufferQueue();
bool is_empty() { return (_head == NULL); }
size_t count();
void enqueue(TraceBuffer *buffer);
TraceBuffer * try_dequeue();
jlong fill_mark() { return _dequeue_ops; }
bool has_dequeued_at_mark(jlong mark) { return (_dequeue_ops >= mark); }
jlong enqueue_ops() { return _enqueue_ops; }
jlong dequeue_ops() { return _dequeue_ops; }
};
#endif /* SHARE_VM_EVTRACE_TRACEBUFFERQUEUE_HPP */