[geos-commits] r3744 - in trunk: include/geos/util src/util

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Jan 14 01:50:57 PST 2013


Author: strk
Date: 2013-01-14 01:50:57 -0800 (Mon, 14 Jan 2013)
New Revision: 3744

Modified:
   trunk/include/geos/util/Interrupt.h
   trunk/src/util/Interrupt.cpp
Log:
Move static class members of Interrupt out of header (#611)

Patch by Mateusz Loskot

Modified: trunk/include/geos/util/Interrupt.h
===================================================================
--- trunk/include/geos/util/Interrupt.h	2013-01-11 17:15:21 UTC (rev 3743)
+++ trunk/include/geos/util/Interrupt.h	2013-01-14 09:50:57 UTC (rev 3744)
@@ -35,13 +35,13 @@
    * Operations will be terminated by a GEOSInterrupt
    * exception at first occasion.
    */
-  static void request() { requested = true; }
+  static void request();
 
   /** Cancel a pending interruption request */
-  static void cancel() { requested = false; }
+  static void cancel();
 
   /** Check if an interruption request is pending */
-  static bool check() { return requested; }
+  static bool check();
 
   /** \brief
    * Register a callback that will be invoked
@@ -53,35 +53,17 @@
    * The callback can be used to call Interrupt::request()
    *
    */
-  static Callback* registerCallback(Callback *cb) {
-    Callback* prev = callback;
-    callback = cb;
-    return prev;
-  }
+  static Callback* registerCallback(Callback *cb);
 
   /**
    * Invoke the callback, if any. Process pending interruption, if any.
    *
    */
-  static void process() {
-    if ( callback ) (*callback)();
-    if ( requested ) {
-      requested = false;
-      interrupt();
-    }
-  }
+  static void process();
 
   /* Perform the actual interruption (simply throw an exception) */
   static void interrupt();
 
-private:
-
-  /* Could these be portably stored in thread-specific space ? */
-
-  static bool requested;
-
-  static Callback *callback;
-
 };
 
 

Modified: trunk/src/util/Interrupt.cpp
===================================================================
--- trunk/src/util/Interrupt.cpp	2013-01-11 17:15:21 UTC (rev 3743)
+++ trunk/src/util/Interrupt.cpp	2013-01-14 09:50:57 UTC (rev 3744)
@@ -15,23 +15,49 @@
 #include <geos/util/Interrupt.h>
 #include <geos/util/GEOSException.h> // for inheritance
 
+namespace {
+  /* Could these be portably stored in thread-specific space ? */
+  bool requested = false;
+
+  geos::util::Interrupt::Callback *callback = 0;
+}
+
 namespace geos {
 namespace util { // geos::util
 
 class GEOS_DLL InterruptedException: public GEOSException {
 public:
-	InterruptedException() :
-		GEOSException("InterruptedException", "Interrupted!") {}
+    InterruptedException() :
+        GEOSException("InterruptedException", "Interrupted!") {}
 };
 
+void Interrupt::request() { requested = true; }
+
+void Interrupt::cancel() { requested = false; }
+
+bool Interrupt::check() { return requested; }
+
+Interrupt::Callback* Interrupt::registerCallback(Interrupt::Callback *cb) {
+    Callback* prev = callback;
+    callback = cb;
+    return prev;
+  }
+
+void Interrupt::process() {
+    if ( callback ) (*callback)();
+    if ( requested ) {
+        requested = false;
+        interrupt();
+    }
+}
+
+
 void
 Interrupt::interrupt() {
   requested = false;
   throw InterruptedException();
 }
 
-bool Interrupt::requested = false;
-Interrupt::Callback *Interrupt::callback = 0;
 
 } // namespace geos::util
 } // namespace geos



More information about the geos-commits mailing list