Consider initializing RateLimiter.mutex eagerly
See original GitHub issueOut of curiosity, what is gained by initializing RateLimiter.mutex()
lazily? Effective Java Item 71 (“Use lazy initialization judiciously”) strongly recommends against lazy initialization unless the object being initialized is expensive to construct. This is certainly not the case for you.
Consider:
- All
RateLimiter
’s public methods require the use ofmutex
. - Removing lazy initialization would simplify the code.
- Performance might improve slightly as you no longer need to check if
mutex
is null over and over again.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
[PATCH 00/12] Posix Alarm Timers full patchset - Google Groups
Initialize everything, well, just everything in Posix clocks/timers ;) ... Serializes access to timerqueue via ops_lock mutex
Read more >Untitled
... Zijlstra) - perf/x86: Reset destroy callback on event init failure (Anand K ... kbuild: mkcompile_h: consider timestamp if KBUILD_BUILD_TIMESTAMP is set ...
Read more >How to Rate Limit HTTP Requests - Alex Edwards
NewLimiter() function to initialize and return a new rate limiter. ... method is protected by a mutex and is safe for concurrent use....
Read more >kernel-automotive-5.14.0-109.70.el9s | Build Info | CentOS ...
(Karol Herbst) [2072020] - locking/ww-mutex: Fix uninitialized use of ret in ... IB/hfi1: Correct guard on eager buffer deallocation (Kamal Heib) [2049164 ...
Read more >kernel-debug-modules-extra-4.18.0-394.el8 RPM for ... - RPMFind
(Michel Dänzer) [2072125] - locking/ww-mutex: Fix uninitialized use of ret in ... mm: teach pfn_to_online_page() to consider subsection validity (Rafael ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
…which is a pretty crazy reason, but it solved the problem 😃
Okay, sad. Feel free to close this issue.