diff --git a/src/update-cb.hh b/src/update-cb.hh index 3cf86552..fb98634f 100644 --- a/src/update-cb.hh +++ b/src/update-cb.hh @@ -85,7 +85,7 @@ namespace conky { friend void conky::run_all_callbacks(); protected: - callback_base(size_t hash_, uint32_t period_, bool wait_, bool use_pipe = false) + callback_base(size_t hash_, uint32_t period_, bool wait_, bool use_pipe) : thread(NULL), hash(hash_), period(period_), remaining(0), pipefd(use_pipe ? pipe2(O_CLOEXEC) : std::pair(-1, -1)), wait(wait_), done(false), unused(0) @@ -94,6 +94,9 @@ namespace conky { int donefd() { return pipefd.first; } + bool is_done() + { return done; } + // to be implemented by descendant classes virtual void work() = 0; @@ -200,16 +203,24 @@ namespace conky { virtual bool operator==(const callback_base &other) { return tuple == dynamic_cast(other).tuple; } - protected: + public: typedef std::tuple Tuple; + protected: const Tuple tuple; Result result; + template + typename std::add_lvalue_reference< + const typename std::tuple_element::type + >::type + get() + { return std::get(tuple); } + public: - callback(uint32_t period_, bool wait_, const Tuple &tuple_) + callback(uint32_t period_, bool wait_, const Tuple &tuple_, bool use_pipe = false) : callback_base(priv::hash_tuple::hash(tuple_), - period_, wait_), + period_, wait_, use_pipe), tuple(tuple_) {}