|
a/src/utils/cancelcheck.h |
|
b/src/utils/cancelcheck.h |
|
... |
|
... |
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#ifndef _CANCELCHECK_H_INCLUDED_
|
17 |
#ifndef _CANCELCHECK_H_INCLUDED_
|
18 |
#define _CANCELCHECK_H_INCLUDED_
|
18 |
#define _CANCELCHECK_H_INCLUDED_
|
19 |
/* @(#$Id: cancelcheck.h,v 1.3 2007-07-12 13:41:54 dockes Exp $ (C) 2005 J.F.Dockes */
|
19 |
/* @(#$Id: cancelcheck.h,v 1.4 2008-11-18 13:24:43 dockes Exp $ (C) 2005 J.F.Dockes */
|
20 |
|
20 |
|
21 |
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Common cancel checking mechanism
|
|
|
24 |
*
|
|
|
25 |
* The CancelCheck class is used as a singleton objet (private constructor).
|
|
|
26 |
* The single instance can be accessed as CancelCheck::instance.
|
|
|
27 |
* It is used as follows, in an asynchronous program where there is an
|
|
|
28 |
* interactive (or otherwise controlling) task and a long-working one:
|
|
|
29 |
* - The control task calls setCancel(), usually as a result of user
|
|
|
30 |
* interaction, if the worker takes too long.
|
|
|
31 |
* - The worker task calls checkCancel() at regular intervals, possibly as
|
|
|
32 |
* a side-effect of some other progress-reporting call. If cancellation has
|
|
|
33 |
* been requested, this will raise an exception.
|
|
|
34 |
* The worker routine must be exception-clean, and the caller should
|
|
|
35 |
* catch the CancelExcept exception.
|
|
|
36 |
*
|
|
|
37 |
*/
|
22 |
class CancelExcept {};
|
38 |
class CancelExcept {};
|
23 |
|
39 |
|
24 |
class CancelCheck {
|
40 |
class CancelCheck {
|
25 |
public:
|
41 |
public:
|
26 |
static CancelCheck& instance() {
|
42 |
static CancelCheck& instance() {
|