GEOS 3.15.0dev
Interrupt.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2012 Sandro Santilli <strk@kbt.io>
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************/
14
15#pragma once
16
17#include <geos/export.h>
18
19namespace geos {
20namespace util { // geos::util
21
23class GEOS_DLL Interrupt {
24
25public:
26
27 typedef void (Callback)(void);
28
36 static void request();
37
39 static void cancel();
40
42 static bool check();
43
54 static Callback* registerCallback(Callback* cb);
55
60 static void process();
61
62 /* Perform the actual interruption (simply throw an exception) */
63 static void interrupt();
64
65};
66
67class GEOS_DLL CurrentThreadInterrupt {
68public:
69 typedef int (ThreadCallback)(void*);
70
77 static ThreadCallback* registerCallback(ThreadCallback* cb, void* data);
78
79 static void process();
80
81 static void interrupt();
82};
83
84
85} // namespace geos::util
86} // namespace geos
87
88
89inline void GEOS_CHECK_FOR_INTERRUPTS() { geos::util::Interrupt::process(); geos::util::CurrentThreadInterrupt::process(); }
Used to manage interruption requests and callbacks.
Definition Interrupt.h:23
static bool check()
static void cancel()
static void process()
static void request()
static Callback * registerCallback(Callback *cb)
Register a callback that will be invoked by all threads before checking for interruption requests.
Basic namespace for all GEOS functionalities.
Definition geos.h:38