From 4b7874c5b67fd2dee435a8f1a60c3820e581ab71 Mon Sep 17 00:00:00 2001 From: javeme Date: Sun, 17 Jul 2016 00:38:43 +0800 Subject: [PATCH] Implement copy constructor for class Monitor To support the instance copy of Monitor like the following: AMQP::Monitor monitor(consumer); consumer->bindExchange(exchange, AMQP::direct).onSuccess([&, monitor](){ // do something when the consumer is ready! if(monitor.valid()) consumer->doSomething(); }); --- include/monitor.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/monitor.h b/include/monitor.h index 9219283..59564f9 100644 --- a/include/monitor.h +++ b/include/monitor.h @@ -57,6 +57,16 @@ public: _watchable->add(this); } + /** + * Copy constructor + * @param monitor + */ + Monitor(const Monitor &monitor) : _watchable(monitor._watchable) + { + // register with the watchable + _watchable->add(this); + } + /** * Destructor */