1 /*
2 Copyright (C) 2013-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: DkWxProcessingController.cpt
12 */
13 
14 /**	@file DkWxProcessingController.h Header file for the DkWxProcessingController module.
15 */
16 
17 #ifndef DKWXPROCESSINGCONTROLLER_H_INCLUDED
18 /** Avoid multiple inclusions. */
19 #define DKWXPROCESSINGCONTROLLER_H_INCLUDED 1
20 
21 
22 #include "dk3conf.h"
23 #include <libdk3c/dk3types.h>
24 #include <libdk3c/dk3const.h>
25 
26 #include <wx/wxprec.h>
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30 #ifndef WX_PRECOMP
31 #include <wx/wx.h>
32 #endif
33 #include <wx/thread.h>
34 
35 
36 
37 /**	Protect code from concurrent execution, mainly for timer handlers.
38 	In contrast to a critical section which delays execution of
39 	code to avoid concurrent access to data this class skips
40 	the execution of concurrent code.
41 */
42 class DkWxProcessingController
43 {
44   protected:
45 
46     /**	Prevent concurrent access.
47     */
48     wxMutex	mxProtectProcessing;
49 
50     /**	Flag: Processing is running.
51     */
52     bool	bIsRunning;
53 
54   public:
55     /**	Default constructor.
56     */
57     DkWxProcessingController();
58 
59     /**	Begin processing if not already running.
60     	If the function returns true you must invoke endProcessing()
61 	when your processing is finished.
62     	@return	true to start processing, false if processing is running.
63     */
64     bool	canBeginProcessing(void);
65 
66     /**	End processing. Call this function after finishing the
67     	critical code.
68     */
69     void	endProcessing(void);
70 };
71 
72 
73 #endif
74