summaryrefslogtreecommitdiff
path: root/src/lib/update.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-07 16:47:44 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-07 16:47:44 +0000
commit16d5c07df7752d093df804d3f1141790f633c24b (patch)
tree7f26d3b870f5fc6cea3987c9088d01f21e7c02b3 /src/lib/update.h
parent185c57d06c9fe5416bb03fad0874ed813db2ffe8 (diff)
Various update bits.
Diffstat (limited to 'src/lib/update.h')
-rw-r--r--src/lib/update.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/lib/update.h b/src/lib/update.h
index b879e9026..a1aefd0a1 100644
--- a/src/lib/update.h
+++ b/src/lib/update.h
@@ -19,6 +19,7 @@
#include <boost/signals2.hpp>
#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
#include <curl/curl.h>
class UpdateChecker
@@ -27,7 +28,7 @@ public:
UpdateChecker ();
~UpdateChecker ();
- void run (bool);
+ void run ();
enum State {
YES,
@@ -46,10 +47,15 @@ public:
return _stable;
}
- /** @return true if this check was run at startup, otherwise false */
- bool startup () const {
+ std::string test () {
boost::mutex::scoped_lock lm (_data_mutex);
- return _startup;
+ return _test;
+ }
+
+ /** @return true if the list signal emission was the first */
+ bool last_emit_was_first () const {
+ boost::mutex::scoped_lock lm (_data_mutex);
+ return _emits == 1;
}
size_t write_callback (void *, size_t, size_t);
@@ -62,18 +68,20 @@ private:
static UpdateChecker* _instance;
void set_state (State);
+ void thread ();
char* _buffer;
int _offset;
CURL* _curl;
- /** mutex to protect _state, _stable and _startup */
+ /** mutex to protect _state, _stable, _test and _emits */
mutable boost::mutex _data_mutex;
State _state;
std::string _stable;
- /** true if this check was run at startup, otherwise false */
- bool _startup;
+ std::string _test;
+ int _emits;
- /** mutex to ensure that only one query runs at once */
- boost::mutex _single_thread_mutex;
+ boost::thread* _thread;
+ boost::mutex _process_mutex;
+ boost::condition _condition;
};