Separate ExceptionStore.
authorCarl Hetherington <cth@carlh.net>
Wed, 26 Aug 2015 21:12:16 +0000 (22:12 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 26 Aug 2015 21:12:16 +0000 (22:12 +0100)
run/tests
src/lib/data.cc
src/lib/encoder.h
src/lib/exception_store.h [new file with mode: 0644]
src/lib/exceptions.h
src/lib/server.h
src/lib/server_finder.h
src/lib/writer.h
src/tools/dcpomatic.cc

index c561cfa99929c93cf26e0c8a017baaf9bec91aa8..49bc63142939caa39b67d4e9c36c8d48e5dc4fff 100755 (executable)
--- a/run/tests
+++ b/run/tests
@@ -10,10 +10,12 @@ if [ "$1" == "--debug" ]; then
 elif [ "$1" == "--valgrind" ]; then
     shift;
     valgrind --tool="memcheck" --leak-check=full build/test/unit-tests $*
+elif [ "$1" == "--callgrind" ]; then
+    shift;
+    valgrind --tool="callgrind" build/test/unit-tests $*
 elif [ "$1" == "--quiet" ]; then
     shift;
     build/test/unit-tests --catch_system_errors=no $*
 else
     build/test/unit-tests --catch_system_errors=no --log_level=test_suite $*
 fi
-
index 5975ff6fc776d8808c1c07089046ad368cc6dffd..eb3ec4c634c1fc2104fe4a1f6301550369c56cc2 100644 (file)
@@ -20,6 +20,7 @@
 #include "data.h"
 #include "cross.h"
 #include "exceptions.h"
+#include <cstdio>
 
 #include "i18n.h"
 
index 12f1e15ffe87b5d1d94cf9d19bdd8cab143fb8dc..fbae07a9a8ebe7cd2a4b20b9f656239631158e6c 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "util.h"
 #include "cross.h"
+#include "exception_store.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/condition.hpp>
diff --git a/src/lib/exception_store.h b/src/lib/exception_store.h
new file mode 100644 (file)
index 0000000..d7c34c0
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef DCPOMATIC_EXCEPTION_STORE_H
+#define DCPOMATIC_EXCEPTION_STORE_H
+
+#include <boost/exception/all.hpp>
+#include <boost/thread/mutex.hpp>
+
+/** @class ExceptionStore
+ *  @brief A parent class for classes which have a need to catch and
+ *  re-throw exceptions.
+ *
+ *  This is intended for classes which run their own thread; they should do
+ *  something like
+ *
+ *  void my_thread ()
+ *  try {
+ *    // do things which might throw exceptions
+ *  } catch (...) {
+ *    store_current ();
+ *  }
+ *
+ *  and then in another thread call rethrow().  If any
+ *  exception was thrown by my_thread it will be stored by
+ *  store_current() and then rethrow() will re-throw it where
+ *  it can be handled.
+ */
+class ExceptionStore
+{
+public:
+       void rethrow () {
+               boost::mutex::scoped_lock lm (_mutex);
+               if (_exception) {
+                       boost::exception_ptr tmp = _exception;
+                       _exception = boost::exception_ptr ();
+                       boost::rethrow_exception (tmp);
+               }
+       }
+
+protected:
+
+       void store_current () {
+               boost::mutex::scoped_lock lm (_mutex);
+               _exception = boost::current_exception ();
+       }
+
+private:
+       boost::exception_ptr _exception;
+       mutable boost::mutex _mutex;
+};
+
+#endif
index 12342b3042748bb64da100da429fe18d7da6803b..7240611ee7757b3acc760ed0acb9f4e2d571e794 100644 (file)
@@ -27,9 +27,7 @@
 extern "C" {
 #include <libavutil/pixfmt.h>
 }
-#include <boost/exception/all.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/thread/mutex.hpp>
 #include <stdexcept>
 #include <cstring>
 
@@ -265,47 +263,4 @@ public:
        ProgrammingError (std::string file, int line);
 };
 
-/** @class ExceptionStore
- *  @brief A parent class for classes which have a need to catch and
- *  re-throw exceptions.
- *
- *  This is intended for classes which run their own thread; they should do
- *  something like
- *
- *  void my_thread ()
- *  try {
- *    // do things which might throw exceptions
- *  } catch (...) {
- *    store_current ();
- *  }
- *
- *  and then in another thread call rethrow().  If any
- *  exception was thrown by my_thread it will be stored by
- *  store_current() and then rethrow() will re-throw it where
- *  it can be handled.
- */
-class ExceptionStore
-{
-public:
-       void rethrow () {
-               boost::mutex::scoped_lock lm (_mutex);
-               if (_exception) {
-                       boost::exception_ptr tmp = _exception;
-                       _exception = boost::exception_ptr ();
-                       boost::rethrow_exception (tmp);
-               }
-       }
-
-protected:
-
-       void store_current () {
-               boost::mutex::scoped_lock lm (_mutex);
-               _exception = boost::current_exception ();
-       }
-
-private:
-       boost::exception_ptr _exception;
-       mutable boost::mutex _mutex;
-};
-
 #endif
index fd765e16037d95cfbb009c4113122d6d64600f3d..97bc26fd896b130d777426a41c680e1a58ca1bbc 100644 (file)
@@ -24,7 +24,7 @@
  *  @brief Server class.
  */
 
-#include "exceptions.h"
+#include "exception_store.h"
 #include <boost/thread.hpp>
 #include <boost/asio.hpp>
 #include <boost/thread/condition.hpp>
index 134759ea3239299f1a996a00a57f4a8ffeaab9a5..bd6d793044ffdf468d41e9b7cecc6950556fb38b 100644 (file)
@@ -20,7 +20,7 @@
 #include "signaller.h"
 #include "server_description.h"
 #include "config.h"
-#include "exceptions.h"
+#include "exception_store.h"
 #include <boost/signals2.hpp>
 #include <boost/thread/condition.hpp>
 
index 3455bfd839797c0444b26c3c0f4df708bc188700..79322bacd154ae93b8eade5eb12fdf7107b19a7f 100644 (file)
@@ -24,6 +24,7 @@
 #include "types.h"
 #include "player_subtitles.h"
 #include "data.h"
+#include "exception_store.h"
 #include <dcp/picture_asset_writer.h>
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
index 1ab316fec73a055ae83c2b0354b1220a9dfc0fa3..7a15475572fe837af9c8885e4906182f1234f52a 100644 (file)
@@ -823,6 +823,7 @@ private:
                TransformProcessType (&serial, kProcessTransformToForegroundApplication);
 #endif
 
+               cout << "set up path encoding.\n";
                dcpomatic_setup_path_encoding ();
 
                /* Enable i18n; this will create a Config object