mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Submit Nick's patch for issue 3589, reviewed by jnoller
This commit is contained in:
		
							parent
							
								
									34bfda55d2
								
							
						
					
					
						commit
						27cc8e1dd2
					
				
					 4 changed files with 32 additions and 132 deletions
				
			
		|  | @ -65,7 +65,9 @@ def __setstate__(self, state): | |||
| # | ||||
| 
 | ||||
| class Semaphore(SemLock): | ||||
| 
 | ||||
|     ''' | ||||
|     A semaphore object | ||||
|     ''' | ||||
|     def __init__(self, value=1): | ||||
|         SemLock.__init__(self, SEMAPHORE, value, SEM_VALUE_MAX) | ||||
| 
 | ||||
|  | @ -84,7 +86,9 @@ def __repr__(self): | |||
| # | ||||
| 
 | ||||
| class BoundedSemaphore(Semaphore): | ||||
| 
 | ||||
|     ''' | ||||
|     A bounded semaphore object | ||||
|     ''' | ||||
|     def __init__(self, value=1): | ||||
|         SemLock.__init__(self, SEMAPHORE, value, value) | ||||
| 
 | ||||
|  | @ -101,7 +105,9 @@ def __repr__(self): | |||
| # | ||||
| 
 | ||||
| class Lock(SemLock): | ||||
| 
 | ||||
|     ''' | ||||
|     A non-recursive lock object | ||||
|     ''' | ||||
|     def __init__(self): | ||||
|         SemLock.__init__(self, SEMAPHORE, 1, 1) | ||||
| 
 | ||||
|  | @ -126,7 +132,9 @@ def __repr__(self): | |||
| # | ||||
| 
 | ||||
| class RLock(SemLock): | ||||
| 
 | ||||
|     ''' | ||||
|     A recursive lock object | ||||
|     ''' | ||||
|     def __init__(self): | ||||
|         SemLock.__init__(self, RECURSIVE_MUTEX, 1, 1) | ||||
| 
 | ||||
|  | @ -152,6 +160,9 @@ def __repr__(self): | |||
| # | ||||
| 
 | ||||
| class Condition(object): | ||||
|     ''' | ||||
|     A condition object | ||||
|     ''' | ||||
| 
 | ||||
|     def __init__(self, lock=None): | ||||
|         self._lock = lock or RLock() | ||||
|  | @ -252,7 +263,9 @@ def notify_all(self): | |||
| # | ||||
| 
 | ||||
| class Event(object): | ||||
| 
 | ||||
|     ''' | ||||
|     An event object | ||||
|     ''' | ||||
|     def __init__(self): | ||||
|         self._cond = Condition(Lock()) | ||||
|         self._flag = Semaphore(0) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jesse Noller
						Jesse Noller