question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider initializing RateLimiter.mutex eagerly

See original GitHub issue

Out 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 of mutex.
  • 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
cpovirkcommented, Mar 11, 2018

…which is a pretty crazy reason, but it solved the problem 😃

0reactions
cowwoccommented, Mar 11, 2018

Okay, sad. Feel free to close this issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found