diff options
author | Norbert Preining <norbert@preining.info> | 2020-09-20 03:03:26 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-09-20 03:03:26 +0000 |
commit | 1f457376b478257b88d4a857f5ec1b6155442dd7 (patch) | |
tree | 2a06a60551dea362cf8cb0cb0ba66c78608717c4 /support/dktools/Dk4WxProcessingController.h | |
parent | ac690ca29ad5bf8a5203a65fd6252f7b564f4727 (diff) |
CTAN sync 202009200303
Diffstat (limited to 'support/dktools/Dk4WxProcessingController.h')
-rw-r--r-- | support/dktools/Dk4WxProcessingController.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/support/dktools/Dk4WxProcessingController.h b/support/dktools/Dk4WxProcessingController.h new file mode 100644 index 0000000000..0be738f135 --- /dev/null +++ b/support/dktools/Dk4WxProcessingController.h @@ -0,0 +1,107 @@ +/* +Copyright (C) 2018-2020, Dirk Krause +SPDX-License-Identifier: BSD-3-Clause +*/ + +/* + WARNING: This file was generated by the dkct program (see + http://dktools.sourceforge.net/ for details). + Changes you make here will be lost if dkct is run again! + You should modify the original source and run dkct on it. + Original source: Dk4WxProcessingController.cpt +*/ + +#ifndef DK4WXPROCESSINGCONTROLLER_H_INCLUDED +/** Avoid multiple inclusions. */ +#define DK4WXPROCESSINGCONTROLLER_H_INCLUDED 1 + + +#line 8 "Dk4WxProcessingController.cpt" + +/** @file Dk4WxProcessingController.h Processing controller to skip + concurrent execution of code accessing the same variables. + + @code + class AnyClass { + protected: + Dk4WxProcessingController procon; + ... + }; + + AnyClass::SomeMethod(void) + { + if (procon.CanEnterCriticalSection()) { + ... Yes, we are allowed to execute code accessing variable ... + ... + ... Notify the controller that we are done ... + procon.LeaveCriticalSection(); + } + else { + ... No, we are not allowed to access the variables ... + } + } + @endcode +*/ + +#ifndef DK4CONF_H_INCLUDED +#include <dk4conf.h> +#endif + +#include <wx/wxprec.h> +#ifdef __BORLANDC__ +#pragma hdrstop +#endif +#ifndef WX_PRECOMP +#include <wx/wx.h> +#endif + +#ifndef WX_THREAD_H_INCLUDED +#include <wx/thread.h> +#define WX_THREAD_H_INCLUDED 1 +#endif + + + +/** Protect code from concurrent execution, mainly for timer handlers. + In contrast to a critical section which delays execution of + code to avoid concurrent access to data this class skips + the execution of concurrent code. +*/ +class Dk4WxProcessingController +{ + protected: + + /** Critical section to protect the "in use" flag. + */ + wxCriticalSection csProtect; + + /** Flag to mark section as currently in use. + */ + bool bInUse; + + public: + + /** Constructor + */ + Dk4WxProcessingController(void); + + /** Check whether the critical code section can be entered. + @return True if the section can be entered, false otherwise. + If the method returns true, the bInUse flag is set, you must + call LeaveCriticalSection() to reset it. + */ + bool + CanEnterCriticalSection(void); + + /** LeaveCriticalSection the critical section. + */ + void + LeaveCriticalSection(void); + +}; + + + +/* vim: set ai sw=4 ts=4 : */ + +#endif |