4 #include "cetlib_except/demangle.h" 5 #include "hep_concurrency/SerialTaskQueue.h" 22 return "An error occurred while attempting to register the shared resource '"s +
28 SharedResource_t::SharedResource_t(
std::string const& resource_name,
30 :
name{demangle ? cet::demangle_symbol(resource_name) : resource_name}
49 <<
"The shared-resources registry has been frozen. All 'serialize' " 51 <<
"must be made in the constructor of a shared module and no later.\n";
64 register_resource(resource.
name);
70 ensure_not_frozen(name);
71 ++resourceCounts_[
name];
82 std::vector<std::pair<unsigned, std::string>> resources_sorted_by_count;
83 for (
auto const& [
name,
count] : resourceCounts_) {
87 resources_sorted_by_count.emplace_back(
count + offset,
name);
89 cet::sort_all(resources_sorted_by_count, [](
auto const&
a,
auto const&
b) {
90 return a.first <
b.first;
93 assert(
empty(sortedResources_));
94 for (
auto const& pr : resources_sorted_by_count) {
95 sortedResources_.emplace_back(pr.second,
96 std::make_shared<SerialTaskQueue>(group));
100 resourceCounts_.clear();
103 std::vector<std::shared_ptr<SerialTaskQueue>>
105 std::vector<std::string>
const& resourceNames)
const 107 std::vector<queue_ptr_t>
result;
112 for (
auto const& pr : sortedResources_) {
113 result.push_back(pr.second);
118 for (
auto const&
name : resourceNames) {
120 std::find_if(
begin(sortedResources_),
121 end(sortedResources_),
122 [&
name](
auto const& pr) {
return pr.first ==
name; });
123 assert(it != sortedResources_.end());
124 result.push_back(it->second);
128 assert(not
empty(result));
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
void ensure_not_frozen(std::string const &name)
std::string demangle(T const *=nullptr)
Outputs a demangled name for type T.
void register_resource(std::string const &name)
void freeze(tbb::task_group &group)
void sort_all(RandCont &)
SharedResource_t const LegacyResource
bool search_all(FwdCont const &, Datum const &)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
auto for_all(FwdCont &, Func)
void registerSharedResources(std::set< std::string > const &names)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
static std::vector< std::string > const names
std::vector< queue_ptr_t > createQueues(std::vector< std::string > const &resourceNames) const
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
void registerSharedResource(detail::SharedResource_t const &)