diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-08-12 15:58:03 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-08-12 15:58:03 -0400 |
commit | a596c1ad2864d639bbab13e7f13fd9f029cf5d93 (patch) | |
tree | 187fe226d7f5f9be5baad36c5cde6986e8a7ba26 /indra/llcommon/throttle.cpp | |
parent | 926a32aa0a9518fe7f19d0c63b30b12a66469f2d (diff) |
Add Throttle and LogThrottle classes to manage throttled APIs.
Diffstat (limited to 'indra/llcommon/throttle.cpp')
-rw-r--r-- | indra/llcommon/throttle.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/indra/llcommon/throttle.cpp b/indra/llcommon/throttle.cpp new file mode 100644 index 0000000000..d5f7d5dcab --- /dev/null +++ b/indra/llcommon/throttle.cpp @@ -0,0 +1,34 @@ +/** + * @file throttle.cpp + * @author Nat Goodspeed + * @date 2024-08-12 + * @brief Implementation for ThrottleBase. + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Copyright (c) 2024, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "linden_common.h" +// associated header +#include "throttle.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "lltimer.h" + +bool ThrottleBase::too_fast() +{ + F64 now = LLTimer::getElapsedSeconds(); + if (now < mNext) + { + return true; + } + else + { + mNext = now + mInterval; + return false; + } +} |