BIND 10 trac2871, updated. bb69cd65951db7b3e4032ede474b81f4e876fbfc [2871] A queue for the land lord
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jul 15 10:23:11 UTC 2013
The branch, trac2871 has been updated
via bb69cd65951db7b3e4032ede474b81f4e876fbfc (commit)
from e6a3f50de3d446541b71bfba4906a6fd77a663f7 (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 bb69cd65951db7b3e4032ede474b81f4e876fbfc
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Jul 15 12:22:58 2013 +0200
[2871] A queue for the land lord
-----------------------------------------------------------------------
Summary of changes:
src/bin/resolver/bench/Makefile.am | 1 +
src/bin/resolver/bench/landlord.cc | 85 ++++++++++++++++++++
.../bench/{naive_resolver.h => landlord.h} | 10 +--
3 files changed, 91 insertions(+), 5 deletions(-)
create mode 100644 src/bin/resolver/bench/landlord.cc
copy src/bin/resolver/bench/{naive_resolver.h => landlord.h} (89%)
-----------------------------------------------------------------------
diff --git a/src/bin/resolver/bench/Makefile.am b/src/bin/resolver/bench/Makefile.am
index 346e007..3e269df 100644
--- a/src/bin/resolver/bench/Makefile.am
+++ b/src/bin/resolver/bench/Makefile.am
@@ -18,6 +18,7 @@ resolver_bench_SOURCES = main.cc
resolver_bench_SOURCES += fake_resolution.h fake_resolution.cc
resolver_bench_SOURCES += dummy_work.h dummy_work.cc
resolver_bench_SOURCES += naive_resolver.h naive_resolver.cc
+resolver_bench_SOURCES += landlord.h landlord.cc
resolver_bench_LDADD = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
resolver_bench_LDADD += $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
diff --git a/src/bin/resolver/bench/landlord.cc b/src/bin/resolver/bench/landlord.cc
new file mode 100644
index 0000000..9d5c08c
--- /dev/null
+++ b/src/bin/resolver/bench/landlord.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <resolver/bench/naive_resolver.h>
+
+#include <util/threads/sync.h>
+
+#include <vector>
+#include <algorithm>
+
+using std::vector;
+using isc::util::thread::CondVar;
+using isc::util::thread::Mutex;
+
+namespace {
+
+template<class T, class Container = std::vector<T> >
+class Queue {
+public:
+ // Constructor.
+ Queue() :
+ shutdown_(false)
+ {}
+ typedef T basetype;
+ typedef Container Values;
+ // Push single value (and wake up if something is waiting on pop()).
+ void push(const T& value) {
+ Values values;
+ values.push_back(value);
+ push(values);
+ }
+ // Push multiple values (and wake up if something is waiting on pop()).
+ void push(const Values& values) {
+ // Copy the data into the queue
+ Mutex::Locker locker(mutex_);
+ values_.insert(values_.end(), values.begin(), values.end());
+ // Wake all threads waiting on new data
+ condvar_.broadcast();
+ }
+ // Signal that we are expected to shutdown. This is out of baund.
+ void shutdown() {
+ Mutex::Locker locker(mutex_);
+ shutdown_ = true;
+ condvar_.broadcast();
+ }
+ // Get some values from the queue. The values are put into where.
+ // It gets maximum of max values, but there may be less. If there
+ // are no values and wait is true, it blocks until some values appear.
+ bool pop(Values &where, size_t max, bool wait = true) {
+ Mutex::Locker locker(mutex_);
+ while (values_.empty() && wait && !shutdown_) {
+ condvar_.wait(mutex_);
+ }
+ size_t amount = std::min(max, values_.size());
+ where.insert(where.end(), values_.begin(), values_.begin() + amount);
+ values_.erase(values_.begin(), values_.begin() + amount);
+ return !shutdown_;
+ }
+private:
+ Values values_;
+ Mutex mutex_;
+ CondVar condvar_;
+ bool shutdown_;
+};
+
+}
+
+namespace isc {
+namespace resolver {
+namespace bench {
+
+}
+}
+}
diff --git a/src/bin/resolver/bench/landlord.h b/src/bin/resolver/bench/landlord.h
new file mode 100644
index 0000000..c3fbb84
--- /dev/null
+++ b/src/bin/resolver/bench/landlord.h
@@ -0,0 +1,44 @@
+// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef RESOLVER_BENCH_LANDLORD_H
+#define RESOLVER_BENCH_LANDLORD_H
+
+#include <resolver/bench/fake_resolution.h>
+
+namespace isc {
+namespace resolver {
+namespace bench {
+
+/// \brief Naive implementation of resolver for the benchmark
+///
+/// This is here mostly to show how to implement the other benchmark
+/// implementations. Look at the code inside how to use the fake
+/// resolution.
+class LandlordResolver {
+public:
+ /// \brief Constructor. Initializes the data.
+ LandlordResolver(size_t query_count);
+ /// \brief Run the resolution.
+ size_t run();
+private:
+ FakeInterface interface_;
+};
+
+}
+}
+}
+
+
+#endif
More information about the bind10-changes
mailing list