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 //! Sets module to the started thread items
46 //! \param theModule a current module
47 Standard_EXPORT void SetModule (DFBrowser_Module* theModule);
49 //! Starts all candidate thread items
50 Standard_EXPORT void ProcessApplication();
52 //! Terminates all started threads.
53 Standard_EXPORT void TerminateThread();
57 //! Creates new Qt thread and starts the item. Connects to finished signal of thread.
58 //! \param theItem a thread item
59 void startThread (DFBrowser_ThreadItem* theItem);
63 //! Removes finished thread from the thread items and apply values of this thread
64 //! If this signal is come when another thread is processed, the current thread is stored in a cache and
65 //! is processed after the previous thread is processed.
70 QList<DFBrowser_ThreadItem*> myItems; //!< candidates to be processed in a thread
71 QList<QThread*> myStartedThreads; //!< container of started threads
72 DFBrowser_ThreadItem* myPostponedItem; //!< currently processed item in onFinished()
73 bool myIsFinishProcessing; //!< blocking state if onFinished() is started but has not been finished yet