File indexing completed on 2024-04-28 15:34:48
0001 /* -*- C++ -*- 0002 This file is part of ThreadWeaver. 0003 0004 SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef WAITFORIDLEANDFINISHED_H 0010 #define WAITFORIDLEANDFINISHED_H 0011 0012 namespace ThreadWeaver 0013 { 0014 class Queue; 0015 } 0016 0017 /** @brief Helper class for tests to ensure that after the scope if left, the queue is idle and resumed. 0018 * Upon destruction, ensure the weaver is idle and suspended. 0019 */ 0020 class WaitForIdleAndFinished 0021 { 0022 public: 0023 explicit WaitForIdleAndFinished(ThreadWeaver::Queue *weaver); 0024 ~WaitForIdleAndFinished(); 0025 WaitForIdleAndFinished(const WaitForIdleAndFinished &) = delete; 0026 WaitForIdleAndFinished &operator=(const WaitForIdleAndFinished &) = delete; 0027 0028 private: 0029 ThreadWeaver::Queue *weaver_; 0030 }; 0031 0032 /** @brief Create a WaitForIdleAndFinished, and suppress the IDE unused warning. */ 0033 /* clang-format off */ 0034 #define WAITFORIDLEANDFINISHED(queue) \ 0035 const WaitForIdleAndFinished waitForIdleAndFinished##__LINE__(queue); \ 0036 Q_UNUSED(waitForIdleAndFinished##__LINE__); 0037 /* clang-format on */ 0038 0039 #endif // WAITFORIDLEANDFINISHED_H