File indexing completed on 2024-04-21 04:01:28

0001 /* -*- C++ -*-
0002     This file declares the ShuttingDownState class.
0003 
0004     SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 
0008     $Id: ShuttingDownState.h 32 2005-08-17 08:38:01Z mirko $
0009 */
0010 
0011 #ifndef ShuttingDownState_H
0012 #define ShuttingDownState_H
0013 
0014 #include "weaverimplstate.h"
0015 
0016 namespace ThreadWeaver
0017 {
0018 class Queue;
0019 
0020 /** ShuttingDownState is enabled when the Weaver destructor is entered. It
0021  *  prevents threads from still accessing queue management methods, and new jobs being queued.
0022  */
0023 class ShuttingDownState : public WeaverImplState
0024 {
0025 public:
0026     explicit ShuttingDownState(QueueSignals *weaver);
0027 
0028     /** Shut down the queue. */
0029     void shutDown() override;
0030     /** Suspend job processing. */
0031     void suspend() override;
0032     /** Resume job processing. */
0033     void resume() override;
0034     /** Assign a job to an idle thread. */
0035     JobPointer applyForWork(Thread *th, bool wasBusy) override;
0036     /** Wait (by suspending the calling thread) until a job becomes available. */
0037     void waitForAvailableJob(Thread *th) override;
0038     /** reimpl */
0039     StateId stateId() const override;
0040 };
0041 
0042 }
0043 
0044 #endif // ShuttingDownState_H