[#absl-Notification]
= xref:absl.adoc[absl]::Notification
:relfileprefix: ../
:mrdocs:

Lets threads wait for a single occurrence of a single event&period;

== Synopsis

Declared in `&lt;absl&sol;synchronization&sol;notification&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Notification;
----

== Description

The `Notification` object maintains a private boolean &quot;notified&quot; state that transitions to `true` at most once&period; The `Notification` class provides the following primary member functions&colon; &ast; `HasBeenNotified()` to query its state &ast; `WaitForNotification&ast;()` to have threads wait until the &quot;notified&quot; state is `true`&period; &ast; `Notify()` to set the notification&apos;s &quot;notified&quot; state to `true` and notify all waiting threads that the event has occurred&period; This method may only be called once&period;

Note that while `Notify()` may only be called once, it is perfectly valid to call any of the `WaitForNotification&ast;()` methods multiple times, from multiple threads &hyphen;&hyphen; even after the notification&apos;s &quot;notified&quot; state has been set &hyphen;&hyphen; in which case those methods will immediately return&period;

Note that the lifetime of a `Notification` requires careful consideration&semi; it might not be safe to destroy a notification after calling `Notify()` since it is still legal for other threads to call `WaitForNotification&ast;()` methods on the notification&period; However, observers responding to a &quot;notified&quot; state of `true` can safely delete the notification without interfering with the call to `Notify()` in the other thread&period;

Memory ordering&colon; For any threads X and Y, if X calls `Notify()`, then any action taken by X before it calls `Notify()` is visible to thread Y after&colon; &ast; Y returns from `WaitForNotification()`, or &ast; Y receives a `true` return value from either `HasBeenNotified()` or `WaitForNotificationWithTimeout()`&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/Notification/2constructor-01.adoc[`Notification`]         [.small]#[constructor]#
| Constructors
| xref:absl/Notification/2destructor.adoc[`&#126;Notification`] [.small]#[destructor]#
| Destroys the notification&period;
| xref:absl/Notification/operator_assign.adoc[`operator&equals;`]  [.small]#[deleted]#
| Deleted copy assignment&semi; `Notification` is not copyable&period;
| xref:absl/Notification/HasBeenNotified.adoc[`HasBeenNotified`] 
| Queries the notification&apos;s &quot;notified&quot; state&period;
| xref:absl/Notification/Notify.adoc[`Notify`] 
| Sets the &quot;notified&quot; state to `true` and wakes waiting threads&period;
| xref:absl/Notification/WaitForNotification.adoc[`WaitForNotification`] 
| Blocks the calling thread until the notification is notified&period;
| xref:absl/Notification/WaitForNotificationWithDeadline.adoc[`WaitForNotificationWithDeadline`] 
| Blocks until the notification is notified or a deadline expires&period;
| xref:absl/Notification/WaitForNotificationWithTimeout.adoc[`WaitForNotificationWithTimeout`] 
| Blocks until the notification is notified or a timeout elapses&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
