Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/ex.rb Secret

Last active June 7, 2018 10:05
Show Gist options
  • Save dminuoso/51023c49eba66de21ac3776ee14003c7 to your computer and use it in GitHub Desktop.
Save dminuoso/51023c49eba66de21ac3776ee14003c7 to your computer and use it in GitHub Desktop.
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