summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse-api/client/helpers.h16
-rw-r--r--gentoobrowse-api/client/search.cpp3
2 files changed, 6 insertions, 13 deletions
diff --git a/gentoobrowse-api/client/helpers.h b/gentoobrowse-api/client/helpers.h
index 5221910..859be3f 100644
--- a/gentoobrowse-api/client/helpers.h
+++ b/gentoobrowse-api/client/helpers.h
@@ -9,27 +9,19 @@ template<typename Key, typename Target, typename Collection, typename Proxy>
std::map<Key, Target>
asyncMapRelated(const Collection & collection, Proxy p,
Key Collection::value_type::element_type::* member,
- Ice::AsyncResultPtr (Proxy::element_type::*f)(Key,
- const ::IceInternal::Function<void (const Target &)> &response,
- const ::IceInternal::Function<void (const ::Ice::Exception &)> &exception,
- const ::IceInternal::Function<void (bool)> & ))
+ Ice::AsyncResultPtr (Proxy::element_type::*b)(Key),
+ Target (Proxy::element_type::*e)(const Ice::AsyncResultPtr &))
{
std::map<Key, Target> rtn;
std::map<Key, Ice::AsyncResultPtr> jobs;
- std::mutex m;
for (const auto & item : collection) {
Key v = item.get()->*member;
if (jobs.find(v) == jobs.end()) {
- jobs.insert({ v, (p.get()->*f)(v, [&rtn, v, &m](const Target & t) {
- m.lock();
- rtn.insert({v, t});
- m.unlock();
- }, [](const ::Ice::Exception & ex) { throw ex; } , nullptr)
- });
+ jobs.insert({ v, (p.get()->*b)(v) });
}
}
for (const auto & j : jobs) {
- j.second->waitForCompleted();
+ rtn.insert({ j.first, (p.get()->*e)(j.second) });
}
return rtn;
}
diff --git a/gentoobrowse-api/client/search.cpp b/gentoobrowse-api/client/search.cpp
index 7ec91be..29d16e2 100644
--- a/gentoobrowse-api/client/search.cpp
+++ b/gentoobrowse-api/client/search.cpp
@@ -10,7 +10,8 @@ class search : public Module {
{
auto pkgs = p->getPackagesSearch(boost::algorithm::join(a, " "));
auto cats = asyncMapRelated(pkgs, p, &Gentoo::Package::categoryid,
- &IceProxy::Gentoo::Portage::begin_getCategory);
+ &IceProxy::Gentoo::Portage::begin_getCategory,
+ &IceProxy::Gentoo::Portage::end_getCategory);
fprintbf(stdout, "Found %d packages:\n", pkgs.size());
for (const auto & pkg : pkgs) {
fprintbf(stdout, "%s / %s\n\t%s\n", cats[pkg->categoryid]->name, pkg->name, pkg->description);