Example #1
0
    bool performance_counter_set::find_counter(counter_info const& info,
        bool reset, error_code& ec)
    {
        // keep only local counters if requested
        if (print_counters_locally_)
        {
            counter_path_elements p;
            get_counter_path_elements(info.fullname_, p, ec);
            if (ec) return false;

            if (p.parentinstanceindex_ != hpx::get_locality_id())
            {
                if (&ec != &throws)
                    ec = make_success_code();
                return true;
            }
        }

        naming::id_type id = get_counter(info.fullname_, ec);
        if (HPX_UNLIKELY(!id))
        {
            HPX_THROWS_IF(ec, bad_parameter,
                "performance_counter_set::find_counter",
                hpx::util::format(
                    "unknown performance counter: '{1}' ({2})",
                    info.fullname_, ec.get_message()));
            return false;
        }

        {
            std::unique_lock<mutex_type> l(mtx_);
            infos_.push_back(info);
            ids_.push_back(id);
            reset_.push_back(reset ? 1 : 0);
        }

        if (&ec != &throws)
            ec = make_success_code();

        return true;
    }
Example #2
0
    bool query_counters::find_counter(
        performance_counters::counter_info const& info, error_code& ec)
    {
        naming::id_type id = performance_counters::get_counter(info.fullname_, ec);
        if (HPX_UNLIKELY(!id))
        {
            HPX_THROWS_IF(ec, bad_parameter,
                "query_counters::find_counter",
                boost::str(boost::format(
                    "unknown performance counter: '%1%' (%2%)") %
                    info.fullname_ % ec.get_message()));
            return false;
        }

        names_.push_back(info.fullname_);
        ids_.push_back(id);
        uoms_.push_back(info.unit_of_measure_);
        types_.push_back(info.type_);

        return true;
    }