@@ -309,11 +309,14 @@ class wait_queue {
309309 * external @c std::stop_token was passed in.
310310 *
311311 */
312- bool request_stop () noexcept {
312+ auto request_stop () noexcept
313+ -> bool {
314+
313315 if (m_stop_src) {
314316 return (*m_stop_src).request_stop ();
315317 }
316318 return false ;
319+
317320 }
318321
319322 /* *
@@ -327,14 +330,17 @@ class wait_queue {
327330 * @return @c true if successful, @c false if the @c wait_queue has been
328331 * requested to stop.
329332 */
330- bool push (const T& val) /* noexcept(std::is_nothrow_copy_constructible<T>::value) */ {
333+ auto push (const T& val) /* noexcept(std::is_nothrow_copy_constructible<T>::value) */
334+ -> bool {
335+
331336 if (m_stop_tok.stop_requested ()) {
332337 return false ;
333338 }
334339 lock_guard lk{m_mut};
335340 m_data_queue.push_back (val);
336341 m_data_cond.notify_one ();
337342 return true ;
343+
338344 }
339345
340346 /* *
@@ -343,14 +349,17 @@ class wait_queue {
343349 * This method has the same semantics as the other @c push, except that the value will
344350 * be moved (if possible) instead of copied.
345351 */
346- bool push (T&& val) /* noexcept(std::is_nothrow_move_constructible<T>::value) */ {
352+ auto push (T&& val) /* noexcept(std::is_nothrow_move_constructible<T>::value) */
353+ -> bool {
354+
347355 if (m_stop_tok.stop_requested ()) {
348356 return false ;
349357 }
350358 lock_guard lk{m_mut};
351359 m_data_queue.push_back (std::move (val));
352360 m_data_cond.notify_one ();
353361 return true ;
362+
354363 }
355364
356365 /* *
@@ -367,14 +376,17 @@ class wait_queue {
367376 * to stop.
368377 */
369378 template <typename ... Args>
370- bool emplace_push (Args &&... args) /* noexcept(std::is_nothrow_constructible<T, Args...>::value)*/ {
379+ auto emplace_push (Args &&... args) /* noexcept(std::is_nothrow_constructible<T, Args...>::value)*/
380+ -> bool {
381+
371382 if (m_stop_tok.stop_requested ()) {
372383 return false ;
373384 }
374385 lock_guard lk{m_mut};
375386 m_data_queue.emplace_back (std::forward<Args>(args)...);
376387 m_data_cond.notify_one ();
377388 return true ;
389+
378390 }
379391
380392 /* *
@@ -388,14 +400,17 @@ class wait_queue {
388400 * @return A value from the @c wait_queue (if non-empty). If the @c std::optional is empty,
389401 * the @c wait_queue has been requested to be stopped.
390402 */
391- std::optional<T> wait_and_pop () /* noexcept(std::is_nothrow_constructible<T>::value) */ {
403+ auto wait_and_pop () /* noexcept(std::is_nothrow_constructible<T>::value) */
404+ -> std::optional<T> {
405+
392406 std::unique_lock<std::mutex> lk{m_mut};
393407 if (!m_data_cond.wait ( lk, m_stop_tok, [this ] { return !m_data_queue.empty (); } )) {
394408 return std::optional<T> {}; // queue was request to stop, no data available
395409 }
396410 std::optional<T> val {std::move_if_noexcept (m_data_queue.front ())}; // move construct if possible
397411 m_data_queue.pop_front ();
398412 return val;
413+
399414 }
400415
401416 /* *
@@ -406,7 +421,9 @@ class wait_queue {
406421 * available in the @c wait_queue or if the @c wait_queue has been requested to be
407422 * stopped .
408423 */
409- std::optional<T> try_pop () /* noexcept(std::is_nothrow_constructible<T>::value) */ {
424+ auto try_pop () /* noexcept(std::is_nothrow_constructible<T>::value) */
425+ -> std::optional<T> {
426+
410427 if (m_stop_tok.stop_requested ()) {
411428 return std::optional<T> {};
412429 }
@@ -417,6 +434,7 @@ class wait_queue {
417434 std::optional<T> val {std::move_if_noexcept (m_data_queue.front ())}; // move construct if possible
418435 m_data_queue.pop_front ();
419436 return val;
437+
420438 }
421439
422440 // non-modifying methods
@@ -447,11 +465,14 @@ class wait_queue {
447465 * same @c wait_queue since it results in recursive mutex locks.
448466 */
449467 template <typename F>
450- void apply (F&& func) const /* noexcept(std::is_nothrow_invocable<F&&, const T&>::value) */ {
468+ auto apply (F&& func) const /* noexcept(std::is_nothrow_invocable<F&&, const T&>::value) */
469+ -> void {
470+
451471 lock_guard lk{m_mut};
452472 for (const T& elem : m_data_queue) {
453473 func (elem);
454474 }
475+
455476 }
456477
457478 /* *
@@ -460,28 +481,37 @@ class wait_queue {
460481 *
461482 * @return @c true if the @c stop_requested has been called.
462483 */
463- bool stop_requested () const noexcept {
484+ auto stop_requested () const noexcept
485+ -> bool {
486+
464487 return m_stop_tok.stop_requested ();
488+
465489 }
466490
467491 /* *
468492 * Query whether the @c wait_queue is empty or not.
469493 *
470494 * @return @c true if the @c wait_queue is empty.
471495 */
472- bool empty () const /* noexcept */ {
496+ auto empty () const /* noexcept */
497+ -> bool {
498+
473499 lock_guard lk{m_mut};
474500 return m_data_queue.empty ();
501+
475502 }
476503
477504 /* *
478505 * Get the number of elements in the @c wait_queue.
479506 *
480507 * @return Number of elements in the @c wait_queue.
481508 */
482- size_type size () const /* noexcept */ {
509+ auto size () const /* noexcept */
510+ -> size_type {
511+
483512 lock_guard lk{m_mut};
484513 return m_data_queue.size ();
514+
485515 }
486516
487517};
0 commit comments