Skip to content

Commit

Permalink
removed redundant comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ndortega committed Oct 15, 2024
1 parent d5481e4 commit 23dc865
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/middleware.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,10 @@ function compose(router::HTTP.Router, cache_lock::ReentrantLock, globalmiddlewar
# Combine all the middleware functions together
strategy = buildmiddleware(key, handler, globalmiddleware, custommiddleware)

## Below Double-checked locking to reduce the overhead of acquiring a lock
# Check if the middleware function is in the cache before locking.
## Below Double-checked locking is used to reduce the overhead of acquiring a lock
if !haskey(middleware_cache, key)
# Lock to ensure only one thread adds to the cache.
lock(cache_lock) do
# Double-check if the function is still not in the cache.
if !haskey(middleware_cache, key)
# Add the function to the cache.
middleware_cache[key] = strategy
end
end
Expand Down

0 comments on commit 23dc865

Please sign in to comment.