Path: blob/master/src/hotspot/share/jfr/writers/jfrMemoryWriterHost.inline.hpp
41149 views
/*1* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_JFR_WRITERS_JFRMEMORYWRITERHOST_INLINE_HPP25#define SHARE_JFR_WRITERS_JFRMEMORYWRITERHOST_INLINE_HPP2627#include "jfr/writers/jfrMemoryWriterHost.hpp"2829template <typename Adapter, typename AP, typename AccessAssert>30inline void MemoryWriterHost<Adapter, AP, AccessAssert>::write_bytes(void* dest, const void* buf, intptr_t len) {31assert(dest != NULL, "invariant");32assert(len >= 0, "invariant");33memcpy(dest, buf, (size_t)len); // no encoding34this->set_current_pos(len);35}3637template <typename Adapter, typename AP, typename AccessAssert>38inline MemoryWriterHost<Adapter, AP, AccessAssert>::MemoryWriterHost(typename Adapter::StorageType* storage, Thread* thread) :39StorageHost<Adapter, AP>(storage, thread) {40}4142template <typename Adapter, typename AP, typename AccessAssert>43inline MemoryWriterHost<Adapter, AP, AccessAssert>::MemoryWriterHost(typename Adapter::StorageType* storage, size_t size) :44StorageHost<Adapter, AP>(storage, size) {45}4647template <typename Adapter, typename AP, typename AccessAssert>48inline MemoryWriterHost<Adapter, AP, AccessAssert>::MemoryWriterHost(Thread* thread) :49StorageHost<Adapter, AP>(thread) {50}5152template <typename Adapter, typename AP, typename AccessAssert>53inline void MemoryWriterHost<Adapter, AP, AccessAssert>::acquire() {54debug_only(_access.acquire();)55if (!this->is_valid()) {56this->flush();57}58debug_only(is_acquired();)59}6061template <typename Adapter, typename AP, typename AccessAssert>62inline void MemoryWriterHost<Adapter, AP, AccessAssert>::release() {63debug_only(is_acquired();)64StorageHost<Adapter, AP>::release();65debug_only(_access.release();)66}6768#ifdef ASSERT69template <typename Adapter, typename AP, typename AccessAssert>70inline bool MemoryWriterHost<Adapter, AP, AccessAssert>::is_acquired() const {71return _access.is_acquired();72}73#endif7475template <typename Adapter, typename AP>76inline AcquireReleaseMemoryWriterHost<Adapter, AP>::AcquireReleaseMemoryWriterHost(typename Adapter::StorageType* storage, Thread* thread) :77MemoryWriterHost<Adapter, AP>(storage, thread) {78this->acquire();79}8081template <typename Adapter, typename AP>82inline AcquireReleaseMemoryWriterHost<Adapter, AP>::AcquireReleaseMemoryWriterHost(typename Adapter::StorageType* storage, size_t size) :83MemoryWriterHost<Adapter, AP>(storage, size) {84this->acquire();85}8687template <typename Adapter, typename AP>88inline AcquireReleaseMemoryWriterHost<Adapter, AP>::AcquireReleaseMemoryWriterHost(Thread* thread) :89MemoryWriterHost<Adapter, AP>(thread) {90this->acquire();91}9293template <typename Adapter, typename AP>94inline AcquireReleaseMemoryWriterHost<Adapter, AP>::~AcquireReleaseMemoryWriterHost() {95assert(this->is_acquired(), "invariant");96this->release();97}9899#endif // SHARE_JFR_WRITERS_JFRMEMORYWRITERHOST_INLINE_HPP100101102