# File lib/needle/thread.rb, line 35 def lock if @locking_thread == Thread.current raise ThreadError, "an attempt was made to reacquire an existing lock " + "(this could happen if you have a circular dependency on a service)" end while (Thread.critical = true; @locked) @waiting.push Thread.current Thread.stop end @locked = true @locking_thread = Thread.current Thread.critical = false self end