aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Getzendanner <durandal@google.com>2024-01-17 13:11:49 -0800
committerCopybara-Service <copybara-worker@google.com>2024-01-17 13:12:24 -0800
commitfe16a5e72d69d8319e53fb8b9c2e9d2b4e43a207 (patch)
tree8a50d39c7932af21cc30c1b985706e1d99eb9316
parent10f3e6117b1154ca8e7e744809d82988f0ff481d (diff)
downloadabseil-fe16a5e72d69d8319e53fb8b9c2e9d2b4e43a207.tar.gz
abseil-fe16a5e72d69d8319e53fb8b9c2e9d2b4e43a207.tar.bz2
abseil-fe16a5e72d69d8319e53fb8b9c2e9d2b4e43a207.zip
Add protected copy ctor+assign to absl::LogSink, and clarify thread-safety requirements to apply to the interface methods.
PiperOrigin-RevId: 599266310 Change-Id: I3b5a91eb17b4b09feba5e048892875f3a747afb1
-rw-r--r--absl/log/log_sink.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/absl/log/log_sink.h b/absl/log/log_sink.h
index 9bfa6f86..2910070d 100644
--- a/absl/log/log_sink.h
+++ b/absl/log/log_sink.h
@@ -32,15 +32,16 @@ ABSL_NAMESPACE_BEGIN
// `absl::LogSink` is an interface which can be extended to intercept and
// process particular messages (with `LOG.ToSinkOnly()` or
// `LOG.ToSinkAlso()`) or all messages (if registered with
-// `absl::AddLogSink`). Implementations must be thread-safe, and should take
-// care not to take any locks that might be held by the `LOG` caller.
+// `absl::AddLogSink`). Implementations must not take any locks that might be
+// held by the `LOG` caller.
class LogSink {
public:
virtual ~LogSink() = default;
// LogSink::Send()
//
- // `Send` is called synchronously during the log statement.
+ // `Send` is called synchronously during the log statement. `Send` must be
+ // thread-safe.
//
// It is safe to use `LOG` within an implementation of `Send`. `ToSinkOnly`
// and `ToSinkAlso` are safe in general but can be used to create an infinite
@@ -50,9 +51,15 @@ class LogSink {
// LogSink::Flush()
//
// Sinks that buffer messages should override this method to flush the buffer
- // and return.
+ // and return. `Flush` must be thread-safe.
virtual void Flush() {}
+ protected:
+ LogSink() = default;
+ // Implementations may be copyable and/or movable.
+ LogSink(const LogSink&) = default;
+ LogSink& operator=(const LogSink&) = default;
+
private:
// https://lld.llvm.org/missingkeyfunction.html#missing-key-function
virtual void KeyFunction() const final; // NOLINT(readability/inheritance)