8234779: Provide idiom for declaring classes noncopyable

Add NONCOPYABLE macro and uses.

Reviewed-by: dholmes, pliden, coleenp
This commit is contained in:
Kim Barrett 2019-12-03 19:09:30 -05:00
parent 3e0a524547
commit 577e87e5b2
37 changed files with 101 additions and 131 deletions

View File

@ -28,6 +28,7 @@
#include "os_aix.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "utilities/globalDefinitions.hpp"
#include CPU_HEADER(vm_version_ext)
@ -884,8 +885,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface;
private:
NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const;

View File

@ -26,6 +26,7 @@
#include "memory/resourceArea.hpp"
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "utilities/globalDefinitions.hpp"
#include CPU_HEADER(vm_version_ext)
#ifdef __APPLE__
@ -72,8 +73,8 @@ class CPUPerformanceInterface::CPUPerformance : public CHeapObj<mtInternal> {
int cpu_load_total_process(double* cpu_load);
int cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad);
CPUPerformance(const CPUPerformance& rhs); // no impl
CPUPerformance& operator=(const CPUPerformance& rhs); // no impl
NONCOPYABLE(CPUPerformance);
public:
CPUPerformance();
bool initialize();
@ -264,8 +265,7 @@ class SystemProcessInterface::SystemProcesses : public CHeapObj<mtInternal> {
private:
SystemProcesses();
bool initialize();
SystemProcesses(const SystemProcesses& rhs); // no impl
SystemProcesses& operator=(const SystemProcesses& rhs); // no impl
NONCOPYABLE(SystemProcesses);
~SystemProcesses();
//information about system processes
@ -407,8 +407,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface;
private:
NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const;

View File

@ -25,6 +25,8 @@
#ifndef OS_BSD_SEMAPHORE_BSD_HPP
#define OS_BSD_SEMAPHORE_BSD_HPP
#include "utilities/globalDefinitions.hpp"
#ifndef __APPLE__
// Use POSIX semaphores.
# include "semaphore_posix.hpp"
@ -37,9 +39,7 @@
class OSXSemaphore : public CHeapObj<mtInternal>{
semaphore_t _semaphore;
// Prevent copying and assignment.
OSXSemaphore(const OSXSemaphore&);
OSXSemaphore& operator=(const OSXSemaphore&);
NONCOPYABLE(OSXSemaphore);
public:
OSXSemaphore(uint value = 0);

View File

@ -28,6 +28,7 @@
#include "os_linux.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "utilities/globalDefinitions.hpp"
#include CPU_HEADER(vm_version_ext)
@ -948,8 +949,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface;
private:
NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int64_t read_counter(const char* iface, const char* counter) const;

View File

@ -26,13 +26,12 @@
#define OS_LINUX_WAITBARRIER_LINUX_HPP
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
class LinuxWaitBarrier : public CHeapObj<mtInternal> {
volatile int _futex_barrier;
// Prevent copying and assignment of LinuxWaitBarrier instances.
LinuxWaitBarrier(const LinuxWaitBarrier&);
LinuxWaitBarrier& operator=(const LinuxWaitBarrier&);
NONCOPYABLE(LinuxWaitBarrier);
public:
LinuxWaitBarrier() : _futex_barrier(0) {};

View File

@ -285,10 +285,8 @@ class PlatformMutex : public CHeapObj<mtSynchronizer> {
#endif // PLATFORM_MONITOR_IMPL_INDIRECT
private:
// Disable copying
PlatformMutex(const PlatformMutex&);
PlatformMutex& operator=(const PlatformMutex&);
private:
NONCOPYABLE(PlatformMutex);
public:
void lock();
@ -329,9 +327,7 @@ class PlatformMonitor : public PlatformMutex {
#endif // PLATFORM_MONITOR_IMPL_INDIRECT
private:
// Disable copying
PlatformMonitor(const PlatformMonitor&);
PlatformMonitor& operator=(const PlatformMonitor&);
NONCOPYABLE(PlatformMonitor);
public:
int wait(jlong millis);

View File

@ -26,15 +26,14 @@
#define OS_POSIX_SEMAPHORE_POSIX_HPP
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#include <semaphore.h>
class PosixSemaphore : public CHeapObj<mtInternal> {
sem_t _semaphore;
// Prevent copying and assignment.
PosixSemaphore(const PosixSemaphore&);
PosixSemaphore& operator=(const PosixSemaphore&);
NONCOPYABLE(PosixSemaphore);
public:
PosixSemaphore(uint value = 0);

View File

@ -28,6 +28,7 @@
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "os_solaris.inline.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include CPU_HEADER(vm_version_ext)
@ -737,8 +738,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface;
private:
NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const;

View File

@ -334,9 +334,7 @@ class PlatformParker : public CHeapObj<mtSynchronizer> {
// Platform specific implementations that underpin VM Mutex/Monitor classes
class PlatformMutex : public CHeapObj<mtSynchronizer> {
// Disable copying
PlatformMutex(const PlatformMutex&);
PlatformMutex& operator=(const PlatformMutex&);
NONCOPYABLE(PlatformMutex);
protected:
mutex_t _mutex; // Native mutex for locking
@ -352,9 +350,8 @@ class PlatformMutex : public CHeapObj<mtSynchronizer> {
class PlatformMonitor : public PlatformMutex {
private:
cond_t _cond; // Native condition variable for blocking
// Disable copying
PlatformMonitor(const PlatformMonitor&);
PlatformMonitor& operator=(const PlatformMonitor&);
NONCOPYABLE(PlatformMonitor);
public:
PlatformMonitor();

View File

@ -30,6 +30,7 @@
#include "pdh_interface.hpp"
#include "runtime/os_perf.hpp"
#include "runtime/os.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include CPU_HEADER(vm_version_ext)
#include <math.h>
@ -1355,8 +1356,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
bool _iphlp_attached;
NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const;

View File

@ -190,9 +190,7 @@ class PlatformParker : public CHeapObj<mtSynchronizer> {
// Platform specific implementations that underpin VM Mutex/Monitor classes
class PlatformMutex : public CHeapObj<mtSynchronizer> {
// Disable copying
PlatformMutex(const PlatformMutex&);
PlatformMutex& operator=(const PlatformMutex&);
NONCOPYABLE(PlatformMutex);
protected:
CRITICAL_SECTION _mutex; // Native mutex for locking
@ -208,9 +206,7 @@ class PlatformMutex : public CHeapObj<mtSynchronizer> {
class PlatformMonitor : public PlatformMutex {
private:
CONDITION_VARIABLE _cond; // Native condition variable for blocking
// Disable copying
PlatformMonitor(const PlatformMonitor&);
PlatformMonitor& operator=(const PlatformMonitor&);
NONCOPYABLE(PlatformMonitor);
public:
PlatformMonitor();

View File

@ -26,15 +26,14 @@
#define OS_WINDOWS_SEMAPHORE_WINDOWS_HPP
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#include <windows.h>
class WindowsSemaphore : public CHeapObj<mtInternal> {
HANDLE _semaphore;
// Prevent copying and assignment.
WindowsSemaphore(const WindowsSemaphore&);
WindowsSemaphore& operator=(const WindowsSemaphore&);
NONCOPYABLE(WindowsSemaphore);
public:
WindowsSemaphore(uint value = 0);

View File

@ -44,9 +44,7 @@ class G1FreeIdSet {
uint head_index(uintx head) const;
uintx make_head(uint index, uintx old_head) const;
// Noncopyable.
G1FreeIdSet(const G1FreeIdSet&);
G1FreeIdSet& operator=(const G1FreeIdSet&);
NONCOPYABLE(G1FreeIdSet);
public:
G1FreeIdSet(uint start, uint size);

View File

@ -37,9 +37,7 @@ class G1SharedDirtyCardQueue {
void** _buffer;
size_t _index;
// Noncopyable
G1SharedDirtyCardQueue(const G1SharedDirtyCardQueue&);
G1SharedDirtyCardQueue& operator=(const G1SharedDirtyCardQueue&);
NONCOPYABLE(G1SharedDirtyCardQueue);
public:
G1SharedDirtyCardQueue(G1DirtyCardQueueSet* qset);

View File

@ -193,9 +193,7 @@ private:
const Block* _head;
const Block* _tail;
// Noncopyable.
AllocationList(const AllocationList&);
AllocationList& operator=(const AllocationList&);
NONCOPYABLE(AllocationList);
public:
AllocationList();

View File

@ -48,9 +48,7 @@ class OopStorage::ActiveArray {
ActiveArray(size_t size);
~ActiveArray();
// Noncopyable
ActiveArray(const ActiveArray&);
ActiveArray& operator=(const ActiveArray&);
NONCOPYABLE(ActiveArray);
static size_t blocks_offset();
Block* const* base_ptr() const;
@ -118,9 +116,7 @@ class OopStorage::AllocationListEntry {
mutable const Block* _prev;
mutable const Block* _next;
// Noncopyable.
AllocationListEntry(const AllocationListEntry&);
AllocationListEntry& operator=(const AllocationListEntry&);
NONCOPYABLE(AllocationListEntry);
public:
AllocationListEntry();
@ -153,9 +149,7 @@ class OopStorage::Block /* No base class, to avoid messing up alignment. */ {
template<typename F, typename BlockPtr>
static bool iterate_impl(F f, BlockPtr b);
// Noncopyable.
Block(const Block&);
Block& operator=(const Block&);
NONCOPYABLE(Block);
public:
const AllocationListEntry& allocation_list_entry() const;

View File

@ -26,7 +26,7 @@
#define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
#include "gc/shared/oopStorage.hpp"
#include "utilities/macros.hpp"
#include "utilities/globalDefinitions.hpp"
//////////////////////////////////////////////////////////////////////////////
// Support for parallel and optionally concurrent state iteration.
@ -134,9 +134,7 @@ class OopStorage::BasicParState {
uint _estimated_thread_count;
bool _concurrent;
// Noncopyable.
BasicParState(const BasicParState&);
BasicParState& operator=(const BasicParState&);
NONCOPYABLE(BasicParState);
struct IterationData;

View File

@ -28,6 +28,7 @@
#include "memory/padded.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/lockFreeStack.hpp"
#include "utilities/sizes.hpp"
@ -44,9 +45,7 @@ class PtrQueueSet;
class PtrQueue {
friend class VMStructs;
// Noncopyable - not defined.
PtrQueue(const PtrQueue&);
PtrQueue& operator=(const PtrQueue&);
NONCOPYABLE(PtrQueue);
// The ptr queue set to which this queue belongs.
PtrQueueSet* const _qset;
@ -205,6 +204,8 @@ class BufferNode {
BufferNode() : _index(0), _next(NULL) { }
~BufferNode() { }
NONCOPYABLE(BufferNode);
static size_t buffer_offset() {
return offset_of(BufferNode, _buffer);
}
@ -273,6 +274,8 @@ class BufferNode::Allocator {
void delete_list(BufferNode* list);
bool try_transfer_pending();
NONCOPYABLE(Allocator);
public:
Allocator(const char* name, size_t buffer_size);
~Allocator();
@ -295,9 +298,7 @@ public:
class PtrQueueSet {
BufferNode::Allocator* _allocator;
// Noncopyable - not defined.
PtrQueueSet(const PtrQueueSet&);
PtrQueueSet& operator=(const PtrQueueSet&);
NONCOPYABLE(PtrQueueSet);
protected:
bool _all_active;

View File

@ -28,6 +28,7 @@
#include "memory/allocation.hpp"
#include "memory/padded.hpp"
#include "oops/oopsHierarchy.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ostream.hpp"
#include "utilities/stack.hpp"
@ -514,9 +515,8 @@ class TaskTerminator : public StackObj {
private:
ParallelTaskTerminator* _terminator;
// Noncopyable.
TaskTerminator(const TaskTerminator&);
TaskTerminator& operator=(const TaskTerminator&);
NONCOPYABLE(TaskTerminator);
public:
TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set);
~TaskTerminator();

View File

@ -30,6 +30,7 @@
#include "gc/shenandoah/shenandoahNMethod.hpp"
#include "memory/allocation.hpp"
#include "memory/iterator.hpp"
#include "utilities/globalDefinitions.hpp"
class ShenandoahHeap;
class ShenandoahHeapRegion;
@ -53,10 +54,8 @@ private:
ShenandoahParallelCodeHeapIterator* _iters;
int _length;
private:
// Noncopyable.
ShenandoahParallelCodeCacheIterator(const ShenandoahParallelCodeCacheIterator& o);
ShenandoahParallelCodeCacheIterator& operator=(const ShenandoahParallelCodeCacheIterator& o);
NONCOPYABLE(ShenandoahParallelCodeCacheIterator);
public:
ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps);
~ShenandoahParallelCodeCacheIterator();

View File

@ -34,6 +34,7 @@
#include "gc/shenandoah/shenandoahSharedVariables.hpp"
#include "gc/shenandoah/shenandoahUnload.hpp"
#include "services/memoryManager.hpp"
#include "utilities/globalDefinitions.hpp"
class ConcurrentGCTimer;
class ReferenceProcessor;
@ -70,8 +71,7 @@ private:
DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0);
// No implicit copying: iterators should be passed by reference to capture the state
ShenandoahRegionIterator(const ShenandoahRegionIterator& that);
ShenandoahRegionIterator& operator=(const ShenandoahRegionIterator& o);
NONCOPYABLE(ShenandoahRegionIterator);
public:
ShenandoahRegionIterator();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved.
* Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.
*
* 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
@ -27,6 +27,7 @@
#include "memory/allocation.hpp"
#include "gc/shenandoah/shenandoahHeap.hpp"
#include "gc/shenandoah/shenandoahHeapRegion.hpp"
#include "utilities/globalDefinitions.hpp"
class ShenandoahHeapRegionSet;
@ -40,8 +41,7 @@ private:
DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0);
// No implicit copying: iterators should be passed by reference to capture the state
ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSetIterator& that);
ShenandoahHeapRegionSetIterator& operator=(const ShenandoahHeapRegionSetIterator& o);
NONCOPYABLE(ShenandoahHeapRegionSetIterator);
public:
ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSet* const set);

View File

@ -25,6 +25,7 @@
#define SHARE_GC_Z_ZARRAY_HPP
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
template <typename T>
class ZArray {
@ -35,9 +36,7 @@ private:
size_t _size;
size_t _capacity;
// Copy and assignment are not allowed
ZArray(const ZArray<T>& array);
ZArray<T>& operator=(const ZArray<T>& array);
NONCOPYABLE(ZArray);
void expand(size_t new_capacity);

View File

@ -25,6 +25,7 @@
#define SHARE_GC_Z_ZLIST_HPP
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
template <typename T> class ZList;
@ -55,9 +56,7 @@ private:
ZListNode<T> _head;
size_t _size;
// Passing by value and assignment is not allowed
ZList(const ZList<T>& list);
ZList<T>& operator=(const ZList<T>& list);
NONCOPYABLE(ZList);
void verify() const;

View File

@ -28,6 +28,7 @@
#include "jni.h"
#include "jfr/utilities/jfrAllocation.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/globalDefinitions.hpp"
class JavaCallArguments;
class JavaThread;
@ -86,8 +87,7 @@ class JfrJavaArguments : public StackObj {
int _java_stack_slots;
Parameters();
Parameters(const Parameters&); // no impl
Parameters& operator=(const Parameters&); // no impl
NONCOPYABLE(Parameters);
void push(const JavaValue& value);
void push_large(const JavaValue& value);

View File

@ -28,6 +28,7 @@
#include "logging/log.hpp"
#include "memory/allocation.hpp"
#include "oops/array.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/hashtable.inline.hpp"
@ -108,9 +109,8 @@ public:
class Ref : public CHeapObj<mtInternal> {
Writability _writability;
Ref* _next;
// Noncopyable.
Ref(const Ref&);
Ref& operator=(const Ref&);
NONCOPYABLE(Ref);
protected:
virtual void** mpp() const = 0;
Ref(Writability w) : _writability(w), _next(NULL) {}

View File

@ -29,6 +29,7 @@
#include "memory/metaspace.hpp"
#include "runtime/atomic.hpp"
#include "utilities/align.hpp"
#include "utilities/globalDefinitions.hpp"
// Array for metadata allocation
@ -49,9 +50,7 @@ protected:
}
private:
// Turn off copy constructor and assignment operator.
Array(const Array<T>&);
void operator=(const Array<T>&);
NONCOPYABLE(Array);
void* operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw() {
size_t word_size = Array::size(length);

View File

@ -26,6 +26,7 @@
#define SHARE_RUNTIME_OS_PERF_HPP
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#define FUNCTIONALITY_NOT_IMPLEMENTED -8
@ -190,9 +191,8 @@ class NetworkInterface : public ResourceObj {
uint64_t _bytes_out;
NetworkInterface* _next;
NetworkInterface(); // no impl
NetworkInterface(const NetworkInterface& rhs); // no impl
NetworkInterface& operator=(const NetworkInterface& rhs); // no impl
NONCOPYABLE(NetworkInterface);
public:
NetworkInterface(const char* name, uint64_t bytes_in, uint64_t bytes_out, NetworkInterface* next) :
_name(NULL),
@ -268,8 +268,8 @@ class NetworkPerformanceInterface : public CHeapObj<mtInternal> {
private:
class NetworkPerformance;
NetworkPerformance* _impl;
NetworkPerformanceInterface(const NetworkPerformanceInterface& rhs); // no impl
NetworkPerformanceInterface& operator=(const NetworkPerformanceInterface& rhs); // no impl
NONCOPYABLE(NetworkPerformanceInterface);
public:
NetworkPerformanceInterface();
bool initialize();

View File

@ -26,6 +26,7 @@
#define SHARE_RUNTIME_SEMAPHORE_HPP
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#if defined(LINUX) || defined(SOLARIS) || defined(AIX)
# include "semaphore_posix.hpp"
@ -43,9 +44,7 @@ class JavaThread;
class Semaphore : public CHeapObj<mtSynchronizer> {
SemaphoreImpl _impl;
// Prevent copying and assignment of Semaphore instances.
Semaphore(const Semaphore&);
Semaphore& operator=(const Semaphore&);
NONCOPYABLE(Semaphore);
public:
Semaphore(uint value = 0) : _impl(value) {}

View File

@ -48,6 +48,7 @@
#include "runtime/unhandledOops.hpp"
#include "utilities/align.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#ifdef ZERO
# include "stack_zero.hpp"
@ -875,9 +876,7 @@ class NonJavaThread::Iterator : public StackObj {
uint _protect_enter;
NonJavaThread* _current;
// Noncopyable.
Iterator(const Iterator&);
Iterator& operator=(const Iterator&);
NONCOPYABLE(Iterator);
public:
Iterator();

View File

@ -27,6 +27,7 @@
#include "memory/allocation.hpp"
#include "runtime/atomic.hpp"
#include "utilities/globalDefinitions.hpp"
// Forward decl;
class BitMapClosure;
@ -390,9 +391,7 @@ class ArenaBitMap : public BitMap {
ArenaBitMap(Arena* arena, idx_t size_in_bits);
private:
// Don't allow copy or assignment.
ArenaBitMap(const ArenaBitMap&);
ArenaBitMap& operator=(const ArenaBitMap&);
NONCOPYABLE(ArenaBitMap);
};
// A BitMap with storage in the CHeap.
@ -401,8 +400,7 @@ class CHeapBitMap : public BitMap {
private:
// Don't allow copy or assignment, to prevent the
// allocated memory from leaking out to other instances.
CHeapBitMap(const CHeapBitMap&);
CHeapBitMap& operator=(const CHeapBitMap&);
NONCOPYABLE(CHeapBitMap);
// NMT memory type
MEMFLAGS _flags;

View File

@ -69,6 +69,19 @@
// This file holds all globally used constants & types, class (forward)
// declarations and a few frequently used utility functions.
// Declare the named class to be noncopyable. This macro must be used in
// a private part of the class's definition, followed by a semi-colon.
// Doing so provides private declarations for the class's copy constructor
// and assignment operator. Because these operations are private, most
// potential callers will fail to compile because they are inaccessible.
// The operations intentionally lack a definition, to provoke link-time
// failures for calls from contexts where they are accessible, e.g. from
// within the class or from a friend of the class.
// Note: The lack of definitions is still not completely bullet-proof, as
// an apparent call might be optimized away by copy elision.
// For C++11 the declarations should be changed to deleted definitions.
#define NONCOPYABLE(C) C(C const&); C& operator=(C const&) /* next token must be ; */
//----------------------------------------------------------------------------------------------------
// Printf-style formatters for fixed- and variable-width types as pointers and
// integers. These are derived from the definitions in inttypes.h. If the platform

View File

@ -27,7 +27,7 @@
#include "runtime/atomic.hpp"
#include "utilities/debug.hpp"
#include "utilities/macros.hpp"
#include "utilities/globalDefinitions.hpp"
// The LockFreeStack class template provides a lock-free LIFO. The objects
// in the sequence are intrusively linked via a member in the objects. As
@ -69,9 +69,7 @@ class LockFreeStack {
} while (old != cur);
}
// Noncopyable.
LockFreeStack(const LockFreeStack&);
LockFreeStack& operator=(const LockFreeStack&);
NONCOPYABLE(LockFreeStack);
public:
LockFreeStack() : _top(NULL) {}

View File

@ -43,8 +43,7 @@ DEBUG_ONLY(class ResourceMark;)
// -XX:+DisplayVMOutputToStderr
class outputStream : public ResourceObj {
private:
outputStream(const outputStream&);
outputStream& operator=(const outputStream&);
NONCOPYABLE(outputStream);
protected:
int _indentation; // current indentation

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -55,9 +55,7 @@ class SingleWriterSynchronizer {
DEBUG_ONLY(volatile uint _writers;)
// Noncopyable.
SingleWriterSynchronizer(const SingleWriterSynchronizer&);
SingleWriterSynchronizer& operator=(const SingleWriterSynchronizer&);
NONCOPYABLE(SingleWriterSynchronizer);
public:
SingleWriterSynchronizer();

View File

@ -28,6 +28,7 @@
#include "memory/allocation.hpp"
#include "runtime/thread.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/waitBarrier_generic.hpp"
#if defined(LINUX)
@ -81,9 +82,7 @@ template <typename WaitBarrierImpl>
class WaitBarrierType : public CHeapObj<mtInternal> {
WaitBarrierImpl _impl;
// Prevent copying and assignment of WaitBarrier instances.
WaitBarrierType(const WaitBarrierDefault&);
WaitBarrierType& operator=(const WaitBarrierDefault&);
NONCOPYABLE(WaitBarrierType);
#ifdef ASSERT
int _last_arm_tag;

View File

@ -27,6 +27,7 @@
#include "memory/allocation.hpp"
#include "runtime/semaphore.hpp"
#include "utilities/globalDefinitions.hpp"
// In addition to the barrier tag, it uses two counters to keep the semaphore
// count correct and not leave any late thread waiting.
@ -39,9 +40,7 @@ class GenericWaitBarrier : public CHeapObj<mtInternal> {
volatile int _barrier_threads;
Semaphore _sem_barrier;
// Prevent copying and assignment of GenericWaitBarrier instances.
GenericWaitBarrier(const GenericWaitBarrier&);
GenericWaitBarrier& operator=(const GenericWaitBarrier&);
NONCOPYABLE(GenericWaitBarrier);
int wake_if_needed();