Commit f5502bfd authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Switch from -defs.h pattern

Summary: [Folly] Switch from `-defs.h` pattern to `-inl.h` pattern in `folly/stats/` since `extern template` doing shallow instantiation rather than deep instantiation makes this pattern difficult.

Reviewed By: chadaustin

Differential Revision: D16761319

fbshipit-source-id: 1760bf53b09791bebf996064c0d1fcc3babf43d2
parent 355677ed
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#pragma once #pragma once
#include <folly/Likely.h> #include <folly/Likely.h>
#include <folly/stats/BucketedTimeSeries.h>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
......
/*
* Copyright 2013-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/stats/BucketedTimeSeries.h>
#include <folly/stats/BucketedTimeSeries-defs.h>
namespace folly {
template class BucketedTimeSeries<int64_t>;
} // namespace folly
...@@ -489,3 +489,5 @@ class BucketedTimeSeries { ...@@ -489,3 +489,5 @@ class BucketedTimeSeries {
}; };
} // namespace folly } // namespace folly
#include <folly/stats/BucketedTimeSeries-inl.h>
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#pragma once #pragma once
#include <folly/Conv.h> #include <folly/Conv.h>
#include <folly/stats/Histogram.h>
#include <glog/logging.h> #include <glog/logging.h>
......
/*
* Copyright 2013-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* This file contains explicit instantiations of stats template types.
*
* This allows most users to avoid having to include the template definition
* header files.
*/
#include <folly/stats/Histogram.h>
#include <folly/stats/Histogram-defs.h>
#if !FOLLY_MSVC_USE_WORKAROUND_FOR_C5037
namespace folly {
template class Histogram<int64_t>;
template class detail::HistogramBuckets<int64_t, Histogram<int64_t>::Bucket>;
// Histogram::getPercentileBucketIdx(), Histogram::getPercentileEstimate()
// and Histogram::computeTotalCount()
// 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 size_t 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;
template uint64_t
detail::HistogramBuckets<int64_t, Histogram<int64_t>::Bucket>::
computeTotalCount<Histogram<int64_t>::CountFromBucket>(
Histogram<int64_t>::CountFromBucket countFromBucket) const;
} // namespace folly
#endif
...@@ -491,18 +491,4 @@ class Histogram { ...@@ -491,18 +491,4 @@ class Histogram {
} // namespace folly } // namespace folly
// MSVC 2017 Update 3/4 has an issue with explicitly instantiating templated #include <folly/stats/Histogram-inl.h>
// functions with default arguments inside templated classes when compiled
// with /permissive- (the default for the CMake build), so we directly include
// the -defs as if it were -inl, and don't provide the explicit instantiations.
// https://developercommunity.visualstudio.com/content/problem/81223/incorrect-error-c5037-with-permissive.html
#if defined(_MSC_VER) && _MSC_FULL_VER >= 191125506 && \
_MSC_FULL_VER <= 191125547
#define FOLLY_MSVC_USE_WORKAROUND_FOR_C5037 1
#else
#define FOLLY_MSVC_USE_WORKAROUND_FOR_C5037 0
#endif
#if FOLLY_MSVC_USE_WORKAROUND_FOR_C5037
#include <folly/stats/Histogram-defs.h>
#endif
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#pragma once #pragma once
#include <folly/stats/MultiLevelTimeSeries.h>
#include <glog/logging.h> #include <glog/logging.h>
namespace folly { namespace folly {
......
/*
* Copyright 2013-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/stats/MultiLevelTimeSeries.h>
#include <folly/stats/MultiLevelTimeSeries-defs.h>
namespace folly {
template class MultiLevelTimeSeries<int64_t>;
} // namespace folly
...@@ -438,3 +438,5 @@ class MultiLevelTimeSeries { ...@@ -438,3 +438,5 @@ class MultiLevelTimeSeries {
}; };
} // namespace folly } // namespace folly
#include <folly/stats/MultiLevelTimeSeries-inl.h>
...@@ -16,10 +16,6 @@ ...@@ -16,10 +16,6 @@
#pragma once #pragma once
#include <folly/stats/QuantileEstimator.h>
#include <folly/stats/detail/BufferedStat-defs.h>
namespace folly { namespace folly {
namespace detail { namespace detail {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <folly/stats/QuantileEstimator-defs.h> #include <folly/stats/QuantileEstimator.h>
namespace folly { namespace folly {
namespace detail { namespace detail {
...@@ -35,7 +35,4 @@ QuantileEstimates estimatesFromDigest( ...@@ -35,7 +35,4 @@ QuantileEstimates estimatesFromDigest(
} // namespace detail } // namespace detail
template class SimpleQuantileEstimator<std::chrono::steady_clock>;
template class SlidingWindowQuantileEstimator<std::chrono::steady_clock>;
} // namespace folly } // namespace folly
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
#pragma once #pragma once
#include <folly/stats/detail/BufferedStatTDigest.h> #include <folly/stats/TDigest.h>
#include <folly/stats/detail/BufferedStat.h>
namespace folly { namespace folly {
...@@ -82,7 +83,6 @@ class SlidingWindowQuantileEstimator { ...@@ -82,7 +83,6 @@ class SlidingWindowQuantileEstimator {
detail::BufferedSlidingWindow<TDigest, ClockT> bufferedSlidingWindow_; detail::BufferedSlidingWindow<TDigest, ClockT> bufferedSlidingWindow_;
}; };
extern template class SimpleQuantileEstimator<std::chrono::steady_clock>;
extern template class SlidingWindowQuantileEstimator<std::chrono::steady_clock>;
} // namespace folly } // namespace folly
#include <folly/stats/QuantileEstimator-inl.h>
...@@ -16,12 +16,6 @@ ...@@ -16,12 +16,6 @@
#pragma once #pragma once
#include <folly/Conv.h>
#include <folly/stats/BucketedTimeSeries-defs.h>
#include <folly/stats/Histogram-defs.h>
#include <folly/stats/MultiLevelTimeSeries-defs.h>
#include <folly/stats/TimeseriesHistogram.h>
namespace folly { namespace folly {
template <typename T, typename CT, typename C> template <typename T, typename CT, typename C>
......
/*
* Copyright 2013-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/stats/TimeseriesHistogram.h>
#include <folly/stats/TimeseriesHistogram-defs.h>
namespace folly {
template class TimeseriesHistogram<int64_t>;
} // namespace folly
...@@ -396,3 +396,5 @@ class TimeseriesHistogram { ...@@ -396,3 +396,5 @@ class TimeseriesHistogram {
ValueType firstValue_; ValueType firstValue_;
}; };
} // namespace folly } // namespace folly
#include <folly/stats/TimeseriesHistogram-inl.h>
...@@ -16,11 +16,6 @@ ...@@ -16,11 +16,6 @@
#pragma once #pragma once
#include <folly/stats/detail/BufferedStat.h>
#include <folly/stats/detail/DigestBuilder-defs.h>
#include <folly/stats/detail/SlidingWindow-defs.h>
namespace folly { namespace folly {
namespace detail { namespace detail {
......
...@@ -147,3 +147,5 @@ class BufferedSlidingWindow : public BufferedStat<DigestT, ClockT> { ...@@ -147,3 +147,5 @@ class BufferedSlidingWindow : public BufferedStat<DigestT, ClockT> {
} // namespace detail } // namespace detail
} // namespace folly } // namespace folly
#include <folly/stats/detail/BufferedStat-inl.h>
/*
* Copyright 2018-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/stats/detail/BufferedStatTDigest.h>
#include <folly/stats/detail/BufferedStat-defs.h>
namespace folly {
namespace detail {
template class BufferedStat<TDigest, std::chrono::steady_clock>;
template class BufferedDigest<TDigest, std::chrono::steady_clock>;
template class BufferedSlidingWindow<TDigest, std::chrono::steady_clock>;
} // namespace detail
} // namespace folly
/*
* Copyright 2018-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <folly/stats/TDigest.h>
#include <folly/stats/detail/BufferedStat.h>
namespace folly {
namespace detail {
extern template class BufferedStat<TDigest, std::chrono::steady_clock>;
extern template class BufferedDigest<TDigest, std::chrono::steady_clock>;
extern template class BufferedSlidingWindow<TDigest, std::chrono::steady_clock>;
} // namespace detail
} // namespace folly
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#pragma once #pragma once
#include <folly/stats/detail/DigestBuilder.h>
#include <algorithm> #include <algorithm>
#include <folly/concurrency/CacheLocality.h> #include <folly/concurrency/CacheLocality.h>
...@@ -93,3 +91,5 @@ void DigestBuilder<DigestT>::append(double value) { ...@@ -93,3 +91,5 @@ void DigestBuilder<DigestT>::append(double value) {
} // namespace detail } // namespace detail
} // namespace folly } // namespace folly
#include <folly/stats/detail/DigestBuilder-inl.h>
...@@ -67,3 +67,5 @@ class DigestBuilder { ...@@ -67,3 +67,5 @@ class DigestBuilder {
} // namespace detail } // namespace detail
} // namespace folly } // namespace folly
#include <folly/stats/detail/DigestBuilder-inl.h>
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#pragma once #pragma once
#include <folly/stats/detail/SlidingWindow.h>
#include <algorithm> #include <algorithm>
namespace folly { namespace folly {
......
...@@ -56,3 +56,5 @@ class SlidingWindow { ...@@ -56,3 +56,5 @@ class SlidingWindow {
} // namespace detail } // namespace detail
} // namespace folly } // namespace folly
#include <folly/stats/detail/SlidingWindow-inl.h>
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <glog/logging.h> #include <glog/logging.h>
#include <folly/Benchmark.h> #include <folly/Benchmark.h>
#include <folly/stats/BucketedTimeSeries-defs.h>
using folly::BenchmarkSuspender; using folly::BenchmarkSuspender;
using folly::BucketedTimeSeries; using folly::BucketedTimeSeries;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <folly/stats/detail/BufferedStat-defs.h> #include <folly/stats/detail/BufferedStat.h>
#include <folly/Range.h> #include <folly/Range.h>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <folly/stats/detail/DigestBuilder-defs.h> #include <folly/stats/detail/DigestBuilder.h>
#include <chrono> #include <chrono>
#include <condition_variable> #include <condition_variable>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <folly/stats/detail/DigestBuilder-defs.h> #include <folly/stats/detail/DigestBuilder.h>
#include <chrono> #include <chrono>
#include <random> #include <random>
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <folly/stats/Histogram.h> #include <folly/stats/Histogram.h>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
#include <folly/stats/Histogram-defs.h>
using folly::Histogram; using folly::Histogram;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <folly/stats/QuantileEstimator-defs.h> #include <folly/stats/QuantileEstimator.h>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <folly/stats/detail/SlidingWindow-defs.h> #include <folly/stats/detail/SlidingWindow.h>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
......
...@@ -14,9 +14,7 @@ ...@@ -14,9 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <folly/stats/BucketedTimeSeries-defs.h>
#include <folly/stats/BucketedTimeSeries.h> #include <folly/stats/BucketedTimeSeries.h>
#include <folly/stats/MultiLevelTimeSeries-defs.h>
#include <folly/stats/MultiLevelTimeSeries.h> #include <folly/stats/MultiLevelTimeSeries.h>
#include <folly/stats/detail/Bucket.h> #include <folly/stats/detail/Bucket.h>
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <random> #include <random>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
#include <folly/stats/TimeseriesHistogram-defs.h>
using namespace std; using namespace std;
using namespace folly; using namespace folly;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <folly/Benchmark.h> #include <folly/Benchmark.h>
#include <folly/portability/GFlags.h> #include <folly/portability/GFlags.h>
#include <folly/portability/PThread.h> #include <folly/portability/PThread.h>
#include <folly/stats/Histogram-defs.h>
#include <folly/stats/Histogram.h> #include <folly/stats/Histogram.h>
namespace { namespace {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment