Skip to content

Commit

Permalink
Add additional instantiations in Instantiations.cpp
Browse files Browse the repository at this point in the history
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<int64_t>.  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<int64_t>::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
  • Loading branch information
simpkins authored and w-o-o committed Feb 2, 2015
1 parent 5667f45 commit 72153cd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions folly/stats/Instantiations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,22 @@ template class detail::HistogramBuckets<int64_t, Histogram<int64_t>::Bucket>;
template class MultiLevelTimeSeries<int64_t>;
template class TimeseriesHistogram<int64_t>;

// 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<int64_t>::Bucket>::
getPercentileBucketIdx<Histogram<int64_t>::CountFromBucket>(
double pct,
Histogram<int64_t>::CountFromBucket countFromBucket,
double* lowPct,
double* highPct) const;
template int64_t detail::HistogramBuckets<int64_t, Histogram<int64_t>::Bucket>
::getPercentileEstimate<Histogram<int64_t>::CountFromBucket,
Histogram<int64_t>::AvgFromBucket>(
double pct,
Histogram<int64_t>::CountFromBucket countFromBucket,
Histogram<int64_t>::AvgFromBucket avgFromBucket) const;

} // folly

0 comments on commit 72153cd

Please sign in to comment.