@@ -52,7 +52,8 @@ class HdrHistogram {
5252
5353 using SyncHdrHistogramPtr = folly::Synchronized<
5454 std::unique_ptr<struct hdr_histogram , HdrDeleter>>;
55- using HistoLockedPtr = SyncHdrHistogramPtr::ConstLockedPtr;
55+ using ConstRHistoLockedPtr = SyncHdrHistogramPtr::ConstRLockedPtr;
56+ using WHistoLockedPtr = SyncHdrHistogramPtr::WLockedPtr;
5657
5758public:
5859 struct Iterator : public hdr_iter {
@@ -142,7 +143,7 @@ class HdrHistogram {
142143 * it being resized or reset while we're reading from the underlying
143144 * data structure.
144145 */
145- HistoLockedPtr histoRLockPtr;
146+ ConstRHistoLockedPtr histoRLockPtr;
146147 };
147148
148149 /* *
@@ -320,25 +321,15 @@ class HdrHistogram {
320321 * @return minimum trackable value
321322 */
322323 uint64_t getMinTrackableValue () const {
323- // We subtract one from the lowest value as we have added a one offset
324- // as the underlying hdr_histogram cannot store 0 and
325- // therefore the value must be greater than or equal to 1.
326- return static_cast <uint64_t >(
327- histogram.rlock ()->get ()->lowest_trackable_value ) -
328- 1 ;
324+ return getMinTrackableValue (histogram.rlock ());
329325 }
330326
331327 /* *
332328 * Method to get the maximum trackable value of this histogram
333329 * @return maximum trackable value
334330 */
335331 uint64_t getMaxTrackableValue () const {
336- // We subtract one from the lowest value as we have added a one offset
337- // as the underlying hdr_histogram cannot store 0 and
338- // therefore the value must be greater than or equal to 1.
339- return static_cast <uint64_t >(
340- histogram.rlock ()->get ()->highest_trackable_value ) -
341- 1 ;
332+ return getMaxTrackableValue (histogram.rlock ());
342333 }
343334
344335 /* *
@@ -348,7 +339,7 @@ class HdrHistogram {
348339 * figures bing used
349340 */
350341 int getSigFigAccuracy () const {
351- return histogram.rlock ()-> get ()-> significant_figures ;
342+ return getSigFigAccuracy ( histogram.rlock ()) ;
352343 }
353344
354345 /* *
@@ -358,10 +349,36 @@ class HdrHistogram {
358349 double getMean () const ;
359350
360351private:
361- void resize (uint64_t lowestTrackableValue,
352+ void resize (WHistoLockedPtr& histoLockPtr,
353+ uint64_t lowestTrackableValue,
362354 uint64_t highestTrackableValue,
363355 int significantFigures);
364356
357+ template <class LockType >
358+ static uint64_t getMinTrackableValue (const LockType& histoLockPtr) {
359+ // We subtract one from the lowest value as we have added a one offset
360+ // as the underlying hdr_histogram cannot store 0 and
361+ // therefore the value must be greater than or equal to 1.
362+ return static_cast <uint64_t >(
363+ histoLockPtr->get ()->lowest_trackable_value ) -
364+ 1 ;
365+ }
366+
367+ template <class LockType >
368+ static uint64_t getMaxTrackableValue (const LockType& histoLockPtr) {
369+ // We subtract one from the lowest value as we have added a one offset
370+ // as the underlying hdr_histogram cannot store 0 and
371+ // therefore the value must be greater than or equal to 1.
372+ return static_cast <uint64_t >(
373+ histoLockPtr->get ()->highest_trackable_value ) -
374+ 1 ;
375+ }
376+
377+ template <class LockType >
378+ static int getSigFigAccuracy (const LockType& histoLockPtr) {
379+ return histoLockPtr->get ()->significant_figures ;
380+ }
381+
365382 /* *
366383 * Private method used to create an iterator for the specified mode
367384 * @param mode the mode of the iterator to be created
0 commit comments