Skip to content

Commit c40f12f

Browse files
committed
doc: update
1 parent bb71669 commit c40f12f

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

components/task/include/task.hpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,12 @@ class Task : public espp::BaseComponent {
6363
* @note The callback is run repeatedly within the Task, therefore it MUST
6464
* return, and also SHOULD have a sleep to give the processor over to
6565
* 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).
7472
*
7573
* @param m mutex associated with the condition variable (should be locked
7674
* before calling cv.wait_for() or cv.wait_until())
@@ -83,7 +81,8 @@ class Task : public espp::BaseComponent {
8381
* a reference to the task's notified member, and is intended to be
8482
* used with the condition variable parameter cv when waiting to avoid
8583
* 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.
8786
*
8887
* @return Whether or not the callback's thread / task should stop - True to
8988
* stop, false to continue running.
@@ -108,9 +107,9 @@ class Task : public espp::BaseComponent {
108107
*
109108
* @warning This is an older callback function signature, and is kept for
110109
* 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.
114113
*
115114
* @param m mutex associated with the condition variable (should be locked
116115
* before calling cv.wait_for() or cv.wait_until())

0 commit comments

Comments
 (0)