message: Make tensorflow's Notification::HasBeenNotified() cheap in the opensource world.
diff: @@ -17,6 +17,7 @@ limitations under the License.
  #define TENSORFLOW_CORE_PLATFORM_DEFAULT_NOTIFICATION_H_
  #include <assert.h>
  +#include <atomic> // NOLINT
  #include <chrono> // NOLINT
  #include <condition_variable> // NOLINT
  @@ -27,24 +28,23 @@ namespace tensorflow {
  class Notification {
  public:
  - Notification() : notified_(false) {}
  + Notification() : notified_(0) {}
  ~Notification() {}
  void Notify() {
  mutex_lock l(mu_);
  - assert(!notified_);
  - notified_ = true;
  + assert(!HasBeenNotified());
  + notified_.store(true, std::memory_order_release);
  cv_.notify_all();
  }
  - bool HasBeenNotified() {
  - mutex_lock l(mu_);
  - return notified_;
  + bool HasBeenNotified() const {
  + return notified_.load(std::memory_order_acquire);
  }
  void WaitForNotification() {
  mutex_lock l(mu_);
  - while (!notified_) {
  + while (!HasBeenNotified()) {
  cv_.wait(l);
  }
  }
  @@ -54,16 +54,16 @@ class Notification {
  int64 timeout_in_us);
  bool WaitForNotificationWithTimeout(int64 timeout_in_us) {
  mutex_lock l(mu_);
  - while (!notified_ &&
  + while (!HasBeenNotified() &&
  cv_.wait_for(l, std::chrono::microseconds(timeout_in_us)) !=
  std::cv_status::timeout) {
  }
  - return notified_;
  + return HasBeenNotified();
  }
  - mutex mu_;
  - condition_variable cv_;
  - bool notified_;
  + mutex mu_; // protects mutations of notified_
  + condition_variable cv_; // signalled when notified_ becomes non-zero
  + std::atomic<bool> notified_; // mutations under mu_
  };
  inline bool WaitForNotificationWithTimeout(Notification* n,
  