Skip to content

Commit

Permalink
Behavior comments
Browse files Browse the repository at this point in the history
Signed-off-by: AssemblyJohn <[email protected]>
  • Loading branch information
AssemblyJohn committed Dec 12, 2024
1 parent 4ac4485 commit 06897bb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions include/ocpp/common/safe_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
namespace ocpp {

enum class EThreadNotifyPolicy {
// Never notify the waiting thread
ThreadNotify_Never,
// Notify the waiting thread when we push an element in the queue
ThreadNotify_Push,
// Notify the waiting thread when we pop an element from the queue
ThreadNotify_Pop,
// Always notify a waiting thread on all operations
ThreadNotify_Always,
};

Expand Down Expand Up @@ -91,9 +95,11 @@ template <typename T, EThreadNotifyPolicy Policy = EThreadNotifyPolicy::ThreadNo
empty.swap(queue);
}

// Clear should make all waiting threads
// wake to check for other states
notify_waiting_thread();
if constexpr (Policy != EThreadNotifyPolicy::ThreadNotify_Never) {
// Clear should make all waiting threads
// wake to check for other states
notify_waiting_thread();
}
}

/// \brief Waits for the queue to receive an element
Expand Down

0 comments on commit 06897bb

Please sign in to comment.