mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	[ci skip][fix GH-589] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
		
			
				
	
	
		
			15 lines
		
	
	
	
		
			448 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
	
		
			448 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
class Thread
 | 
						|
  MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new # :nodoc:
 | 
						|
 | 
						|
  # call-seq:
 | 
						|
  #    Thread.exclusive { block }   => obj
 | 
						|
  #
 | 
						|
  # Wraps the block in a single, VM-global Mutex.synchronize, returning the
 | 
						|
  # value of the block. A thread executing inside the exclusive section will
 | 
						|
  # only block other threads which also use the Thread.exclusive mechanism.
 | 
						|
  def self.exclusive
 | 
						|
    MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
 | 
						|
      yield
 | 
						|
    }
 | 
						|
  end
 | 
						|
end
 |