Add fix for index out of bounds during high load

pull/765/head
Omar Roth 2019-09-24 13:38:08 -04:00
rodzic 4361ea9686
commit f69f0b97f5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B8254FB7EC3D37F2
1 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

@ -237,3 +237,16 @@ class HTTP::Client
response
end
end
struct Crystal::ThreadLocalValue(T)
@values = Hash(Thread, T).new
def get(&block : -> T)
th = Thread.current
if !@values[th]?
@values[th] = yield
else
@values[th]
end
end
end