From: David Callahan Date: Tue, 1 Nov 2016 19:56:08 +0000 (-0700) Subject: Fix CLANG compilation: folly/TokenBucket.h X-Git-Tag: v2016.11.07.00~17 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=f490576e697794b1a803fc280700a4364f5d3b24;p=folly.git Fix CLANG compilation: folly/TokenBucket.h Summary: In the next revision of clang, compilation generates multiple erroes of the form folly/TokenBucket.h:127:29: error: exception specification is not available until end of class definition double nowInSeconds = defaultClockNow()) { which are eliminated by reordering the method declaration for defaultClockNow() Refer https://llvm.org/bugs/show_bug.cgi?id=30860 Reviewed By: philippu, yfeldblum Differential Revision: D4107443 fbshipit-source-id: ce64f2ae7983e533c2fcb5cb043dbdd3da5c00f7 --- diff --git a/folly/TokenBucket.h b/folly/TokenBucket.h index 7ddf8fc2..ce6a0551 100644 --- a/folly/TokenBucket.h +++ b/folly/TokenBucket.h @@ -104,6 +104,15 @@ class ParameterizedDynamicTokenBucket { zeroTime_ = zeroTime; } + /** + * Returns the current time in seconds since Epoch. + */ + static double defaultClockNow() noexcept(noexcept(ClockT::timeSinceEpoch())) { + return std::chrono::duration_cast>( + ClockT::timeSinceEpoch()) + .count(); + } + /** * Attempts to consume some number of tokens. Tokens are first added to the * bucket based on the time elapsed since the last attempt to consume tokens. @@ -191,15 +200,6 @@ class ParameterizedDynamicTokenBucket { return std::min((nowInSeconds - this->zeroTime_) * rate, burstSize); } - /** - * Returns the current time in seconds since Epoch. - */ - static double defaultClockNow() noexcept(noexcept(ClockT::timeSinceEpoch())) { - return std::chrono::duration_cast>( - ClockT::timeSinceEpoch()) - .count(); - } - private: template bool consumeImpl( @@ -268,6 +268,13 @@ class ParameterizedTokenBucket { ParameterizedTokenBucket& operator=( const ParameterizedTokenBucket& other) noexcept = default; + /** + * Returns the current time in seconds since Epoch. + */ + static double defaultClockNow() noexcept(noexcept(Impl::defaultClockNow())) { + return Impl::defaultClockNow(); + } + /** * Change rate and burst size. * @@ -370,13 +377,6 @@ class ParameterizedTokenBucket { return burstSize_; } - /** - * Returns the current time in seconds since Epoch. - */ - static double defaultClockNow() noexcept(noexcept(Impl::defaultClockNow())) { - return Impl::defaultClockNow(); - } - private: Impl tokenBucket_; double rate_;