File indexing completed on 2024-05-19 07:50:52
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 void finish(); 0028 0029 private: 0030 ThreadWeaver::Queue *weaver_; 0031 }; 0032 0033 /** @brief Create a WaitForIdleAndFinished, and suppress the IDE unused warning. */ 0034 /* clang-format off */ 0035 #define WAITFORIDLEANDFINISHED(queue) \ 0036 const WaitForIdleAndFinished waitForIdleAndFinished##__LINE__(queue); \ 0037 Q_UNUSED(waitForIdleAndFinished##__LINE__); 0038 /* clang-format on */ 0039 0040 #endif // WAITFORIDLEANDFINISHED_H