diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-24 19:49:14 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-24 19:49:14 +0100 |
| commit | 17830349b580b5933589f2b739671828b5cfc208 (patch) | |
| tree | 9b81623c16cf4d899458a87d32337c4b7b7b0e39 /src/lib | |
| parent | bd8fa9a370f1739952c83107352baa08c79d095e (diff) | |
Cross-thread UI signalling.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 3 | ||||
| -rw-r--r-- | src/lib/ui_signaller.cc | 23 | ||||
| -rw-r--r-- | src/lib/ui_signaller.h | 51 | ||||
| -rw-r--r-- | src/lib/wscript | 1 |
4 files changed, 77 insertions, 1 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 7ce56138a..b76f9df71 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -51,6 +51,7 @@ #include "config.h" #include "check_hashes_job.h" #include "version.h" +#include "ui_signaller.h" using namespace std; using namespace boost; @@ -1190,7 +1191,7 @@ void Film::signal_changed (Property p) { _dirty = true; - Changed (p); + ui_signaller->emit (boost::bind (boost::ref (Changed), p)); } int diff --git a/src/lib/ui_signaller.cc b/src/lib/ui_signaller.cc new file mode 100644 index 000000000..4f39a6187 --- /dev/null +++ b/src/lib/ui_signaller.cc @@ -0,0 +1,23 @@ +/* + Copyright (C) 2012 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. + +*/ + +#include "ui_signaller.h" + +UISignaller* ui_signaller = 0; + diff --git a/src/lib/ui_signaller.h b/src/lib/ui_signaller.h new file mode 100644 index 000000000..6b0e73c60 --- /dev/null +++ b/src/lib/ui_signaller.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2012 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 DVDOMATIC_UI_SIGNALLER_H +#define DVDOMATIC_UI_SIGNALLER_H + +#include <boost/bind.hpp> +#include <boost/asio.hpp> + +class UISignaller +{ +public: + UISignaller () + : _work (_service) + {} + + template <class S> + void emit (S signal) { + _service.post (boost::bind (boost::ref (signal))); + } + + void ui_idle () { + _service.poll (); + } + + virtual void wake_ui () = 0; + +private: + boost::asio::io_service _service; + boost::asio::io_service::work _work; +}; + +extern UISignaller* ui_signaller; + +#endif diff --git a/src/lib/wscript b/src/lib/wscript index af8b4b7d3..4f1fa0636 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -48,6 +48,7 @@ def build(bld): timer.cc transcode_job.cc transcoder.cc + ui_signaller.cc util.cc version.cc """ |
