Skip to content
Permalink
Browse files
8234779: Provide idiom for declaring classes noncopyable
Add NONCOPYABLE macro and uses.

Reviewed-by: yan
Backport-of: 577e87e
  • Loading branch information
Olga Mikhaltsova authored and Yuri Nesterenko committed Mar 22, 2021
1 parent 44dfa89 commit 3186873e7ff4c2695839154b3ce4e27abb875d50
Showing 37 changed files with 101 additions and 109 deletions.
@@ -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)

@@ -893,8 +894,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;
@@ -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
@@ -412,8 +412,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;
@@ -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);
@@ -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)

@@ -957,8 +958,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;
@@ -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) {};
@@ -286,6 +286,9 @@ class PlatformMonitor : public CHeapObj<mtSynchronizer> {

#endif // PLATFORM_MONITOR_IMPL_INDIRECT

private:
NONCOPYABLE(PlatformMonitor);

public:
void lock();
void unlock();
@@ -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);
@@ -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)
@@ -745,8 +746,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;
@@ -341,6 +341,8 @@ class PlatformMonitor : public CHeapObj<mtSynchronizer> {
mutex_t _mutex; // Native mutex for locking
cond_t _cond; // Native condition variable for blocking

NONCOPYABLE(PlatformMonitor);

public:
PlatformMonitor();
~PlatformMonitor();
@@ -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>
@@ -1369,8 +1370,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;
@@ -194,6 +194,8 @@ class PlatformMonitor : public CHeapObj<mtSynchronizer> {
CRITICAL_SECTION _mutex; // Native mutex for locking
CONDITION_VARIABLE _cond; // Native condition variable for blocking

NONCOPYABLE(PlatformMonitor);

public:
PlatformMonitor();
~PlatformMonitor();
@@ -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);
@@ -45,9 +45,7 @@ class G1FreeIdSet : public CHeapObj<mtGC> {
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);
@@ -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);
@@ -196,9 +196,7 @@ NOT_AIX( private: )
const Block* _head;
const Block* _tail;

// Noncopyable.
AllocationList(const AllocationList&);
AllocationList& operator=(const AllocationList&);
NONCOPYABLE(AllocationList);

public:
AllocationList();
@@ -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;
@@ -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;

@@ -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);
}
@@ -274,6 +275,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();
@@ -309,6 +312,8 @@ class PtrQueueSet {

void assert_completed_buffers_list_len_correct_locked() NOT_DEBUG_RETURN;

NONCOPYABLE(PtrQueueSet);

protected:
bool _all_active;

@@ -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();
@@ -29,6 +29,7 @@
#include "gc/shenandoah/shenandoahLock.hpp"
#include "memory/allocation.hpp"
#include "memory/iterator.hpp"
#include "utilities/globalDefinitions.hpp"

class ShenandoahHeap;
class ShenandoahHeapRegion;
@@ -52,10 +53,8 @@ class ShenandoahParallelCodeCacheIterator {
ShenandoahParallelCodeHeapIterator* _iters;
int _length;

private:
// Noncopyable.
ShenandoahParallelCodeCacheIterator(const ShenandoahParallelCodeCacheIterator& o);
ShenandoahParallelCodeCacheIterator& operator=(const ShenandoahParallelCodeCacheIterator& o);
NONCOPYABLE(ShenandoahParallelCodeCacheIterator);

public:
ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps);
~ShenandoahParallelCodeCacheIterator();

1 comment on commit 3186873

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 3186873 Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.