@@ -63,14 +63,12 @@ class Task : public espp::BaseComponent {
63
63
* @note The callback is run repeatedly within the Task, therefore it MUST
64
64
* return, and also SHOULD have a sleep to give the processor over to
65
65
* other tasks. For this reason, the callback is provided a
66
- * std::condition_variable (and associated mutex) which the callback
67
- * can use when they need to wait. If the cv.wait_for / cv.wait_until
68
- * return <a href="https://en.cppreference.com/w/cpp/thread/cv_status">
69
- * std::cv_status::timeout</a>, no action is necessary, but if they
70
- * return <a href="https://en.cppreference.com/w/cpp/thread/cv_status">
71
- * std::cv_status::no_timeout</a>, then the function should return
72
- * immediately since the task is being stopped (optionally performing
73
- * any task-specific tear-down).
66
+ * std::condition_variable (and associated mutex) which the callback can
67
+ * use when they need to wait. If the cv.wait_for / cv.wait_until return
68
+ * false, no action is necessary (as the timeout properly occurred / the
69
+ * task was not notified). If they return true, then the callback
70
+ * function should return immediately since the task is being stopped
71
+ * (optionally performing any task-specific tear-down).
74
72
*
75
73
* @param m mutex associated with the condition variable (should be locked
76
74
* before calling cv.wait_for() or cv.wait_until())
@@ -83,7 +81,8 @@ class Task : public espp::BaseComponent {
83
81
* a reference to the task's notified member, and is intended to be
84
82
* used with the condition variable parameter cv when waiting to avoid
85
83
* spurious wakeups. The task function is responsible for clearing this
86
- * flag after each wait.
84
+ * flag after each wait. Do not release the lock on the mutex m until
85
+ * the notified flag has been checked and cleared.
87
86
*
88
87
* @return Whether or not the callback's thread / task should stop - True to
89
88
* stop, false to continue running.
@@ -108,9 +107,9 @@ class Task : public espp::BaseComponent {
108
107
*
109
108
* @warning This is an older callback function signature, and is kept for
110
109
* backwards compatibility. It is recommended to use the newer callback
111
- * signature which includes the notified parameter, enabling the task
112
- * callback function to wait on the condition variable and ignore
113
- * spurious wakeups.
110
+ * signature (callback_m_cv_notified_fn) which includes the notified
111
+ * parameter, enabling the task callback function to wait on the
112
+ * condition variable and ignore spurious wakeups.
114
113
*
115
114
* @param m mutex associated with the condition variable (should be locked
116
115
* before calling cv.wait_for() or cv.wait_until())
0 commit comments