1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef DFBrowser_Thread_H
17 #define DFBrowser_Thread_H
19 #include <Standard.hxx>
21 #include <Standard_WarningsDisable.hxx>
24 #include <Standard_WarningsRestore.hxx>
26 class DFBrowser_Module;
27 class DFBrowser_ThreadItem;
28 class DFBrowser_Window;
32 //! /class DFBrowser_Thread
33 //! Starts algorithm item in a separate thread and perform some functionality by the algorithm(thread) is finished
34 class DFBrowser_Thread : public QObject
40 Standard_EXPORT DFBrowser_Thread (DFBrowser_Window* theWindow);
43 virtual ~DFBrowser_Thread() {}
45 //! Starts all candidate thread items
46 Standard_EXPORT void ProcessApplication();
48 //! Terminates all started threads.
49 Standard_EXPORT void TerminateThread();
53 //! Creates new Qt thread and starts the item. Connects to finished signal of thread.
54 //! \param theItem a thread item
55 void startThread (DFBrowser_ThreadItem* theItem);
59 //! Removes finished thread from the thread items and apply values of this thread
60 //! If this signal is come when another thread is processed, the current thread is stored in a cache and
61 //! is processed after the previous thread is processed.
66 QList<DFBrowser_ThreadItem*> myItems; //!< candidates to be processed in a thread
67 QList<QThread*> myStartedThreads; //!< container of started threads
68 DFBrowser_ThreadItem* myPostponedItem; //!< currently processed item in onFinished()
69 bool myIsFinishProcessing; //!< blocking state if onFinished() is started but has not been finished yet
70 Standard_Boolean myIsProcessPostponed; //!< state if process application should be done by finish active thread