@@ -52,7 +52,8 @@ class HdrHistogram {
52
52
53
53
using SyncHdrHistogramPtr = folly::Synchronized<
54
54
std::unique_ptr<struct hdr_histogram , HdrDeleter>>;
55
- using HistoLockedPtr = SyncHdrHistogramPtr::ConstLockedPtr;
55
+ using ConstRHistoLockedPtr = SyncHdrHistogramPtr::ConstRLockedPtr;
56
+ using WHistoLockedPtr = SyncHdrHistogramPtr::WLockedPtr;
56
57
57
58
public:
58
59
struct Iterator : public hdr_iter {
@@ -142,7 +143,7 @@ class HdrHistogram {
142
143
* it being resized or reset while we're reading from the underlying
143
144
* data structure.
144
145
*/
145
- HistoLockedPtr histoRLockPtr;
146
+ ConstRHistoLockedPtr histoRLockPtr;
146
147
};
147
148
148
149
/* *
@@ -320,25 +321,15 @@ class HdrHistogram {
320
321
* @return minimum trackable value
321
322
*/
322
323
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 ());
329
325
}
330
326
331
327
/* *
332
328
* Method to get the maximum trackable value of this histogram
333
329
* @return maximum trackable value
334
330
*/
335
331
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 ());
342
333
}
343
334
344
335
/* *
@@ -348,7 +339,7 @@ class HdrHistogram {
348
339
* figures bing used
349
340
*/
350
341
int getSigFigAccuracy () const {
351
- return histogram.rlock ()-> get ()-> significant_figures ;
342
+ return getSigFigAccuracy ( histogram.rlock ()) ;
352
343
}
353
344
354
345
/* *
@@ -358,10 +349,36 @@ class HdrHistogram {
358
349
double getMean () const ;
359
350
360
351
private:
361
- void resize (uint64_t lowestTrackableValue,
352
+ void resize (WHistoLockedPtr& histoLockPtr,
353
+ uint64_t lowestTrackableValue,
362
354
uint64_t highestTrackableValue,
363
355
int significantFigures);
364
356
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
+
365
382
/* *
366
383
* Private method used to create an iterator for the specified mode
367
384
* @param mode the mode of the iterator to be created
0 commit comments