BIND 10 #2205: introduce a "data source configurator" thread in auth
BIND 10 Development
do-not-reply at isc.org
Mon Sep 3 08:59:23 UTC 2012
#2205: introduce a "data source configurator" thread in auth
-------------------------------------+-------------------------------------
Reporter: | Owner:
jinmei | Status: new
Type: task | Milestone: Next-Sprint-
Priority: | Proposed
medium | Resolution:
Component: | Sensitive: 0
b10-auth | Sub-Project: DNS
Keywords: | Estimated Difficulty: 0
Defect Severity: N/A | Total Hours: 0
Feature Depending on Ticket: |
background zone loading |
Add Hours to Ticket: 0 |
Internal?: 0 |
-------------------------------------+-------------------------------------
Comment (by vorner):
Hello
Replying to [comment:4 jinmei]:
> I'm not sure if I fully understand above. Can you provide some
> sample code snippet to illustrate the idea more specifically?
OK. I'll skip details like condition variables, mutexes, etc. Let's say we
have
a `SynchronizedQueue` container that allows to put objects in and take
them out
in separate threads, the taking blocks if there's no object.
{{{#!c++
class WorkThread {
private:
SynchronizedQueue<boost::function<void ()> > queue_;
public:
// Called from the "main" thread. Never blocks.
void asyncWork(boost::function<void ()> work) {
queue_.push_back(work);
}
// Running "for ever" in the work/background thread.
void run() {
for (;;) {
boost::function<void ()> work =
queue_.pop_front();
work();
}
}
};
}}}
Then, if we want to handle configuration update, we do something like
this:
{{{#!c++
// This one runs a long time, should be run in background
void handleDatasrcConfig(const isc::data::ConstElementPtr& config) {
...
}
void configHandler(const isc::data::ConstElementPtr& config) {
...
workThread.asyncWork(boost::bind(handleDatasrcConfig,
config->get("data_sources")));
...
}
}}}
I hope it explains the idea.
> In any case, specific ways to implement it is up to the developer
> (and the reviewer, and if it's controversial on review we can discuss
> it project wide). The approach mentioned in the description is just
> an example to give a better idea of what should be done, and doesn't
> have to be adopted literally.
Indeed. I just wanted to share the idea if the implementor finds it
usable,
because it seems to me the technique is elegant, but mostly unknown in the
procedural world.
--
Ticket URL: <http://bind10.isc.org/ticket/2205#comment:5>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development
More information about the bind10-tickets
mailing list