Skip to content

Commit

Permalink
NFC: replace uses of TF_DISALLOW_COPY_AND_ASSIGN/SE_DISALLOW_COPY_AND…
Browse files Browse the repository at this point in the history
…_ASSIGN macros with implementation.

PiperOrigin-RevId: 570296712
  • Loading branch information
chsigg authored and copybara-github committed Oct 3, 2023
1 parent 8ad01d1 commit 7a19856
Show file tree
Hide file tree
Showing 62 changed files with 175 additions and 86 deletions.
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/distributed_runtime/call_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class CallOptions {
// RPC operation timeout in milliseconds.
int64_t timeout_in_ms_ TF_GUARDED_BY(mu_) = 0;

TF_DISALLOW_COPY_AND_ASSIGN(CallOptions);
CallOptions(const CallOptions&) = delete;
void operator=(const CallOptions&) = delete;
};

} // namespace tsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ class CoordinationServiceStandaloneImpl : public CoordinationServiceInterface {

absl::flat_hash_set<std::string> recoverable_jobs_;

TF_DISALLOW_COPY_AND_ASSIGN(CoordinationServiceStandaloneImpl);
CoordinationServiceStandaloneImpl(const CoordinationServiceStandaloneImpl&) =
delete;
void operator=(const CoordinationServiceStandaloneImpl&) = delete;
};

void CoordinationServiceStandaloneImpl::TaskState::SetConnected(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class CoordinationServiceAgentImpl : public CoordinationServiceAgent {
CancellationManager cancellation_manager_;
std::unique_ptr<CoordinationClient> leader_client_;

TF_DISALLOW_COPY_AND_ASSIGN(CoordinationServiceAgentImpl);
CoordinationServiceAgentImpl(const CoordinationServiceAgentImpl&) = delete;
void operator=(const CoordinationServiceAgentImpl&) = delete;
};

Status CoordinationServiceAgentImpl::Initialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class GrpcCoordinationServiceImpl : public AsyncServiceInterface {
std::unique_ptr<::grpc::ServerCompletionQueue> cq_;
tensorflow::grpc::CoordinationService::AsyncService service_;

TF_DISALLOW_COPY_AND_ASSIGN(GrpcCoordinationServiceImpl);
GrpcCoordinationServiceImpl(const GrpcCoordinationServiceImpl&) = delete;
void operator=(const GrpcCoordinationServiceImpl&) = delete;
};

} // namespace tsl
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/distributed_runtime/rpc/grpc_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ class SparseGrpcChannelCache : public CachingGrpcChannelCache {
const string job_id_;
const std::map<int, string> host_ports_;
const ChannelCreationFunction channel_func_;
TF_DISALLOW_COPY_AND_ASSIGN(SparseGrpcChannelCache);
SparseGrpcChannelCache(const SparseGrpcChannelCache&) = delete;
void operator=(const SparseGrpcChannelCache&) = delete;
};

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class GrpcClientCQTag {
virtual void OnCompleted(bool ok) = 0;

private:
TF_DISALLOW_COPY_AND_ASSIGN(GrpcClientCQTag);
GrpcClientCQTag(const GrpcClientCQTag&) = delete;
void operator=(const GrpcClientCQTag&) = delete;
};

} // namespace tsl
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/framework/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ struct AllocationAttributes {
// returned.
std::function<uint64()>* freed_by_func = nullptr; // Not owned.

TF_DISALLOW_COPY_AND_ASSIGN(AllocationAttributes);
AllocationAttributes(const AllocationAttributes&) = delete;
void operator=(const AllocationAttributes&) = delete;
};

// Runtime statistics collected by an allocator. Exactly the same as
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/framework/allocator_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ class AllocatorFactoryRegistry {
const FactoryEntry* FindEntry(const string& name, int priority) const
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);

TF_DISALLOW_COPY_AND_ASSIGN(AllocatorFactoryRegistry);
AllocatorFactoryRegistry(const AllocatorFactoryRegistry&) = delete;
void operator=(const AllocatorFactoryRegistry&) = delete;
};

class AllocatorFactoryRegistration {
Expand Down
6 changes: 4 additions & 2 deletions third_party/tsl/tsl/framework/bfc_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ class BFCAllocator : public Allocator {
// for the memory allocation represented by "p"
std::vector<ChunkHandle> handles_;

TF_DISALLOW_COPY_AND_ASSIGN(AllocationRegion);
AllocationRegion(const AllocationRegion&) = delete;
void operator=(const AllocationRegion&) = delete;
};

// RegionManager aggregates one or more "AllocationRegions" and provides
Expand Down Expand Up @@ -619,7 +620,8 @@ class BFCAllocator : public Allocator {

friend class GPUBFCAllocatorPrivateMethodsTest;
friend class GPUBFCAllocatorPrivateMethodsTest_SubAllocatorSpecific;
TF_DISALLOW_COPY_AND_ASSIGN(BFCAllocator);
BFCAllocator(const BFCAllocator&) = delete;
void operator=(const BFCAllocator&) = delete;
};

} // namespace tsl
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/framework/cpu_allocator_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ class CPUAllocator : public Allocator {
std::atomic<int> single_allocation_warning_count_;
int total_allocation_warning_count_ TF_GUARDED_BY(mu_);

TF_DISALLOW_COPY_AND_ASSIGN(CPUAllocator);
CPUAllocator(const CPUAllocator&) = delete;
void operator=(const CPUAllocator&) = delete;
};

class CPUAllocatorFactory : public AllocatorFactory {
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/framework/device_id_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class TfToPlatformDeviceIdMap {
TypeIdMapType id_map_ TF_GUARDED_BY(mu_);

friend class ::tsl::DeviceIdManager;
TF_DISALLOW_COPY_AND_ASSIGN(TfToPlatformDeviceIdMap);
TfToPlatformDeviceIdMap(const TfToPlatformDeviceIdMap&) = delete;
void operator=(const TfToPlatformDeviceIdMap&) = delete;
};
} // namespace

Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/histogram/histogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class Histogram {

double Remap(double x, double x0, double x1, double y0, double y1) const;

TF_DISALLOW_COPY_AND_ASSIGN(Histogram);
Histogram(const Histogram&) = delete;
void operator=(const Histogram&) = delete;
};

// Wrapper around a Histogram object that is thread safe.
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/buffered_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class BufferedWritableFile : public WritableFile {
std::unique_ptr<WritableFile> file_;
uint32_t crc32_ = 0;

TF_DISALLOW_COPY_AND_ASSIGN(BufferedWritableFile);
BufferedWritableFile(const BufferedWritableFile&) = delete;
void operator=(const BufferedWritableFile&) = delete;
};

} // namespace tsl
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/buffered_inputstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class BufferedInputStream : public InputStreamInterface {
// buffer allocations.
Status file_status_ = OkStatus();

TF_DISALLOW_COPY_AND_ASSIGN(BufferedInputStream);
BufferedInputStream(const BufferedInputStream&) = delete;
void operator=(const BufferedInputStream&) = delete;
};

// Explicit instantiations defined in buffered_inputstream.cc.
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/inputbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class InputBuffer {
char* pos_; // Current position in "buf"
char* limit_; // Just past end of valid data in "buf"

TF_DISALLOW_COPY_AND_ASSIGN(InputBuffer);
InputBuffer(const InputBuffer&) = delete;
void operator=(const InputBuffer&) = delete;
};

// Implementation details.
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/record_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ class RecordReader {

std::unique_ptr<Metadata> cached_metadata_;

TF_DISALLOW_COPY_AND_ASSIGN(RecordReader);
RecordReader(const RecordReader&) = delete;
void operator=(const RecordReader&) = delete;
};

// High-level interface to read TFRecord files.
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/record_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ class RecordWriter {
}
#endif

TF_DISALLOW_COPY_AND_ASSIGN(RecordWriter);
RecordWriter(const RecordWriter&) = delete;
void operator=(const RecordWriter&) = delete;
};

void RecordWriter::PopulateHeader(char* header, const char* data, size_t n) {
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/snappy/snappy_inputbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ class SnappyInputBuffer : public InputStreamInterface {
// Number of *uncompressed* bytes that have been read from this stream.
int64_t bytes_read_;

TF_DISALLOW_COPY_AND_ASSIGN(SnappyInputBuffer);
SnappyInputBuffer(const SnappyInputBuffer&) = delete;
void operator=(const SnappyInputBuffer&) = delete;
};

} // namespace io
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/snappy/snappy_inputstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class SnappyInputStream : public InputStreamInterface {
// is not yet read.
size_t avail_out_;

TF_DISALLOW_COPY_AND_ASSIGN(SnappyInputStream);
SnappyInputStream(const SnappyInputStream&) = delete;
void operator=(const SnappyInputStream&) = delete;
};

} // namespace io
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/snappy/snappy_outputbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ class SnappyOutputBuffer : public WritableFile {
char* next_out_;
size_t avail_out_;

TF_DISALLOW_COPY_AND_ASSIGN(SnappyOutputBuffer);
SnappyOutputBuffer(const SnappyOutputBuffer&) = delete;
void operator=(const SnappyOutputBuffer&) = delete;
};

} // namespace io
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/zlib_inputstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ class ZlibInputStream : public InputStreamInterface {
// Number of *uncompressed* bytes that have been read from this stream.
int64_t bytes_read_;

TF_DISALLOW_COPY_AND_ASSIGN(ZlibInputStream);
ZlibInputStream(const ZlibInputStream&) = delete;
void operator=(const ZlibInputStream&) = delete;
};

} // namespace io
Expand Down
3 changes: 2 additions & 1 deletion third_party/tsl/tsl/lib/io/zlib_outputbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ class ZlibOutputBuffer : public WritableFile {
return flush_mode == Z_SYNC_FLUSH || flush_mode == Z_FULL_FLUSH;
}

TF_DISALLOW_COPY_AND_ASSIGN(ZlibOutputBuffer);
ZlibOutputBuffer(const ZlibOutputBuffer&) = delete;
void operator=(const ZlibOutputBuffer&) = delete;
};

} // namespace io
Expand Down
9 changes: 6 additions & 3 deletions third_party/tsl/tsl/lib/monitoring/collection_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class CollectionRegistry {
private:
CollectionRegistry() {}

TF_DISALLOW_COPY_AND_ASSIGN(CollectionRegistry);
CollectionRegistry(const CollectionRegistry&) = delete;
void operator=(const CollectionRegistry&) = delete;
};

} // namespace monitoring
Expand Down Expand Up @@ -273,7 +274,8 @@ class CollectionRegistry {
};
std::map<StringPiece, CollectionInfo> registry_ TF_GUARDED_BY(mu_);

TF_DISALLOW_COPY_AND_ASSIGN(CollectionRegistry);
CollectionRegistry(const CollectionRegistry&) = delete;
void operator=(const CollectionRegistry&) = delete;
};

////
Expand Down Expand Up @@ -397,7 +399,8 @@ class Collector {
std::unique_ptr<CollectedMetrics> collected_metrics_ TF_GUARDED_BY(mu_);
const uint64 collection_time_millis_;

TF_DISALLOW_COPY_AND_ASSIGN(Collector);
Collector(const Collector&) = delete;
void operator=(const Collector&) = delete;
};

// Write the timestamps for the point based on the MetricKind.
Expand Down
12 changes: 8 additions & 4 deletions third_party/tsl/tsl/lib/monitoring/counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class CounterCell {
int64 value() const { return 0; }

private:
TF_DISALLOW_COPY_AND_ASSIGN(CounterCell);
CounterCell(const CounterCell&) = delete;
void operator=(const CounterCell&) = delete;
};

// Counter which has a null implementation.
Expand All @@ -68,7 +69,8 @@ class Counter {

CounterCell default_counter_cell_;

TF_DISALLOW_COPY_AND_ASSIGN(Counter);
Counter(const Counter&) = delete;
void operator=(const Counter&) = delete;
};

} // namespace monitoring
Expand Down Expand Up @@ -117,7 +119,8 @@ class CounterCell {
private:
std::atomic<int64_t> value_;

TF_DISALLOW_COPY_AND_ASSIGN(CounterCell);
CounterCell(const CounterCell&) = delete;
void operator=(const CounterCell&) = delete;
};

// A stateful class for updating a cumulative integer metric.
Expand Down Expand Up @@ -189,7 +192,8 @@ class Counter {

std::unique_ptr<CollectionRegistry::RegistrationHandle> registration_handle_;

TF_DISALLOW_COPY_AND_ASSIGN(Counter);
Counter(const Counter&) = delete;
void operator=(const Counter&) = delete;
};

////
Expand Down
18 changes: 12 additions & 6 deletions third_party/tsl/tsl/lib/monitoring/gauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class GaugeCell {
T value() const { return T(); }

private:
TF_DISALLOW_COPY_AND_ASSIGN(GaugeCell);
GaugeCell(const GaugeCell&) = delete;
void operator=(const GaugeCell&) = delete;
};

// Gauge which has a null implementation.
Expand Down Expand Up @@ -81,7 +82,8 @@ class Gauge {

GaugeCell<ValueType> default_gauge_cell_;

TF_DISALLOW_COPY_AND_ASSIGN(Gauge);
Gauge(const Gauge&) = delete;
void operator=(const Gauge&) = delete;
};

} // namespace monitoring
Expand Down Expand Up @@ -131,7 +133,8 @@ class GaugeCell {
T value_ TF_GUARDED_BY(mu_);
mutable mutex mu_;

TF_DISALLOW_COPY_AND_ASSIGN(GaugeCell);
GaugeCell(const GaugeCell&) = delete;
void operator=(const GaugeCell&) = delete;
};

// Explicit specialization of GaugeCell<int64_t>. Compared to the primary
Expand All @@ -152,7 +155,8 @@ class GaugeCell<int64_t> {
private:
std::atomic<int64_t> value_;

TF_DISALLOW_COPY_AND_ASSIGN(GaugeCell);
GaugeCell(const GaugeCell&) = delete;
void operator=(const GaugeCell&) = delete;
};

// Explicit specialization of GaugeCell<bool>. Compared to the primary
Expand All @@ -173,7 +177,8 @@ class GaugeCell<bool> {
private:
std::atomic<bool> value_;

TF_DISALLOW_COPY_AND_ASSIGN(GaugeCell);
GaugeCell(const GaugeCell&) = delete;
void operator=(const GaugeCell&) = delete;
};

// A stateful class for updating a gauge-like metric. Allowed ValueType are
Expand Down Expand Up @@ -254,7 +259,8 @@ class Gauge {

std::unique_ptr<CollectionRegistry::RegistrationHandle> registration_handle_;

TF_DISALLOW_COPY_AND_ASSIGN(Gauge);
Gauge(const Gauge&) = delete;
void operator=(const Gauge&) = delete;
};

////
Expand Down
9 changes: 6 additions & 3 deletions third_party/tsl/tsl/lib/monitoring/percentile_sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class PercentileSampler {

PercentileSampler() = default;

TF_DISALLOW_COPY_AND_ASSIGN(PercentileSampler);
PercentileSampler(const PercentileSampler&) = delete;
void operator=(const PercentileSampler&) = delete;
};

template <int NumLabels>
Expand Down Expand Up @@ -134,7 +135,8 @@ class PercentileSamplerCell {
size_t total_samples_ TF_GUARDED_BY(mu_);
long double accumulator_ TF_GUARDED_BY(mu_);

TF_DISALLOW_COPY_AND_ASSIGN(PercentileSamplerCell);
PercentileSamplerCell(const PercentileSamplerCell&) = delete;
void operator=(const PercentileSamplerCell&) = delete;
};

// A stateful class for updating a cumulative percentile sampled metric.
Expand Down Expand Up @@ -242,7 +244,8 @@ class PercentileSampler {
// Registration handle with the CollectionRegistry.
std::unique_ptr<CollectionRegistry::RegistrationHandle> registration_handle_;

TF_DISALLOW_COPY_AND_ASSIGN(PercentileSampler);
PercentileSampler(const PercentileSampler&) = delete;
void operator=(const PercentileSampler&) = delete;
};

template <int NumLabels>
Expand Down
Loading

0 comments on commit 7a19856

Please sign in to comment.