Skip to content

Commit

Permalink
pw_sync: Add initial state of (Timed)ThreadNotification
Browse files Browse the repository at this point in the history
Both ThreadNotification and TimedThreadNotification lack explicit
information about initial state. This CL adds this information to the
documentation.

Change-Id: I23421929e1b51ef5d1857add06ce9a5d186d6609
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/96882
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
  • Loading branch information
dkormalev authored and CQ Bot Account committed Jun 3, 2022
1 parent cd44cfd commit 8617fa7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pw_sync/docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,8 @@ backed by the most efficient native primitive for a target, regardless of
whether that is a semaphore, event flag group, condition variable, or something
else.

The ThreadNotification is initialized to being empty (latch is not set).

Generic BinarySemaphore-based Backend
-------------------------------------
This module provides a generic backend for ``pw::sync::ThreadNotification`` via
Expand Down Expand Up @@ -1362,6 +1364,8 @@ TimedThreadNotification
The TimedThreadNotification is an extension of the ThreadNotification which
offers timeout and deadline based semantics.

The TimedThreadNotification is initialized to being empty (latch is not set).

.. Warning::
This is a single consumer/waiter, multiple producer/notifier API!
The acquire APIs must only be invoked by a single consuming thread. As a
Expand Down
2 changes: 2 additions & 0 deletions pw_sync/public/pw_sync/binary_semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ namespace pw::sync {
// the user and/or backend MUST ensure that any initialization required in your
// environment is done prior to the creation and/or initialization of the native
// synchronization primitives (e.g. kernel initialization).
//
// The BinarySemaphore is initialized to being empty or having no tokens.
class BinarySemaphore {
public:
using native_handle_type = backend::NativeBinarySemaphoreHandle;
Expand Down
2 changes: 2 additions & 0 deletions pw_sync/public/pw_sync/counting_semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace pw::sync {
// the user and/or backend MUST ensure that any initialization required in your
// environment is done prior to the creation and/or initialization of the native
// synchronization primitives (e.g. kernel initialization).
//
// The CountingSemaphore is initialized to being empty or having no tokens.
class CountingSemaphore {
public:
using native_handle_type = backend::NativeCountingSemaphoreHandle;
Expand Down
2 changes: 2 additions & 0 deletions pw_sync/public/pw_sync/thread_notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace pw::sync {
//
// The single consumer aspect of the API permits the use of a smaller and/or
// faster native APIs such as direct thread signaling.
//
// The ThreadNotification is initialized to being empty (latch is not set).
class ThreadNotification {
public:
using native_handle_type = backend::NativeThreadNotificationHandle;
Expand Down
2 changes: 2 additions & 0 deletions pw_sync/public/pw_sync/timed_thread_notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace pw::sync {
//
// The single consumer aspect of the API permits the use of a smaller and/or
// faster native APIs such as direct thread signaling.
//
// The TimedThreadNotification is initialized to being empty (latch is not set).
class TimedThreadNotification : public ThreadNotification {
public:
TimedThreadNotification() = default;
Expand Down

0 comments on commit 8617fa7

Please sign in to comment.