From 72153cdf1d938ecad9f02bc23edcb84ea67d2731 Mon Sep 17 00:00:00 2001 From: Adam Simpkins Date: Thu, 15 Jan 2015 18:35:56 -0800 Subject: [PATCH] Add additional instantiations in Instantiations.cpp Summary: Histogram::getPercentileBucketIdx() and getPercentileEstimate() are implemented using template methods of HistogramBuckets. This updates Instantiations.cpp to also instantiate the versions of these template methods that are required by Histogram. Without this, anyone using these methods was required to also include Histogram-defs.h, or otherwise they may get link errors. This makes it so they no longer need to include Histogram-defs.h The C++ syntax required is pretty horrendous. We could potentially avoid this by refactoring the code so that these methods are no longer templates (and require that the Bucket class provide methods for this purpose). At the moment adding instantiations seems simpler, and doesn't change any public APIs. Test Plan: Successfully linked code using Histogram::getPercentileEstimate() without including Histogram-defs.h Reviewed By: ldbrandy@fb.com, meyering@fb.com Subscribers: trunkagent, doug, net-systems@, exa, folly-diffs@ FB internal diff: D1786346 Signature: t1:1786346:1421429734:da17b7ea326c64a1e158fec3b87dc49c3db3d848 --- folly/stats/Instantiations.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/folly/stats/Instantiations.cpp b/folly/stats/Instantiations.cpp index 2b6f926d..cc35b678 100644 --- a/folly/stats/Instantiations.cpp +++ b/folly/stats/Instantiations.cpp @@ -41,4 +41,22 @@ template class detail::HistogramBuckets::Bucket>; template class MultiLevelTimeSeries; template class TimeseriesHistogram; +// Histogram::getPercentileBucketIdx() and Histogram::getPercentileEstimate() +// are implemented using template methods. Instantiate the default versions of +// these methods too, so anyone using them won't also need to explicitly +// include Histogram-defs.h +template unsigned int detail::HistogramBuckets< + int64_t, Histogram::Bucket>:: + getPercentileBucketIdx::CountFromBucket>( + double pct, + Histogram::CountFromBucket countFromBucket, + double* lowPct, + double* highPct) const; +template int64_t detail::HistogramBuckets::Bucket> + ::getPercentileEstimate::CountFromBucket, + Histogram::AvgFromBucket>( + double pct, + Histogram::CountFromBucket countFromBucket, + Histogram::AvgFromBucket avgFromBucket) const; + } // folly -- 2.34.1