BIND 10 trac957, updated. 49ae23f163b8e4ad45f7146f95235253691a0f4b [trac957] apply review comments
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jun 10 06:31:46 UTC 2011
The branch, trac957 has been updated
via 49ae23f163b8e4ad45f7146f95235253691a0f4b (commit)
from 1ff545f50926224d095e3809636c642219ea9078 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 49ae23f163b8e4ad45f7146f95235253691a0f4b
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Fri Jun 10 15:24:46 2011 +0900
[trac957] apply review comments
-----------------------------------------------------------------------
Summary of changes:
src/lib/asiolink/interval_timer.cc | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/asiolink/interval_timer.cc b/src/lib/asiolink/interval_timer.cc
index 502bf80..9873e9b 100644
--- a/src/lib/asiolink/interval_timer.cc
+++ b/src/lib/asiolink/interval_timer.cc
@@ -14,10 +14,6 @@
#include <config.h>
-#include <unistd.h> // for some IPC/network system calls
-#include <sys/socket.h>
-#include <netinet/in.h>
-
#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
@@ -31,8 +27,13 @@
namespace isc {
namespace asiolink {
-/// This class uses shared_from_this in its methods. It must live inside
-/// a shared_ptr.
+/// This class holds a call back function of asynchronous operations.
+/// To ensure the object is alive while an asynchronous operation refers
+/// to it, we use shared_ptr and enable_shared_from_this.
+/// The object will be destructed in case IntervalTimer has been destructed
+/// and no asynchronous operation refers to it.
+/// Please follow the link to get an example:
+/// http://think-async.com/asio/asio-1.4.8/doc/asio/tutorial/tutdaytime3.html#asio.tutorial.tutdaytime3.the_tcp_connection_class
class IntervalTimerImpl :
public boost::enable_shared_from_this<IntervalTimerImpl>
{
@@ -99,13 +100,15 @@ IntervalTimerImpl::update() {
// Update expire time to (current time + interval_).
timer_.expires_from_now(boost::posix_time::millisec(interval_));
// Reset timer.
+ // Pass a function bound with a shared_ptr to this.
timer_.async_wait(boost::bind(&IntervalTimerImpl::callback,
shared_from_this(),
asio::placeholders::error));
} catch (const asio::system_error& e) {
- isc_throw(isc::Unexpected, "Failed to update timer");
- } catch (const boost::bad_weak_ptr& e) {
- isc_throw(isc::Unexpected, "Failed to update timer");
+ isc_throw(isc::Unexpected, "Failed to update timer: " << e.what());
+ } catch (const boost::bad_weak_ptr&) {
+ // Can't happen. It means a severe internal bug.
+ assert(0);
}
}
More information about the bind10-changes
mailing list