Skip to content

Instantly share code, notes, and snippets.

@machu
Created June 5, 2010 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save machu/426433 to your computer and use it in GitHub Desktop.
Save machu/426433 to your computer and use it in GitHub Desktop.
require 'thread'
module Safe
def safe( level = 4 )
result = nil
if $SAFE < level then
Thread.start {
$SAFE = level
result = yield
}.join
else
result = yield
end
result
end
module_function :safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment