-
-
Save dminuoso/51023c49eba66de21ac3776ee14003c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pool = TVar.new([]) | |
t = Thread.new do | |
loop do | |
key = compute_rsa_key | |
Concurrent.atomically do | |
if Pool.value.length > 10 | |
raise Transaction::AbortError | |
end | |
Pool.value.push key | |
end | |
end | |
end | |
t.join | |
def on_request | |
rsa = nil | |
Concurrent.atomically do | |
rsa = Pool.value.pop | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment