mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Revert 60189 and restore performance.
This commit is contained in:
		
							parent
							
								
									7a6eacd2ca
								
							
						
					
					
						commit
						70ec29d0f4
					
				
					 1 changed files with 24 additions and 8 deletions
				
			
		|  | @ -347,18 +347,27 @@ def isSet(self): | ||||||
|         return self.__flag |         return self.__flag | ||||||
| 
 | 
 | ||||||
|     def set(self): |     def set(self): | ||||||
|         with self.__cond: |         self.__cond.acquire() | ||||||
|  |         try: | ||||||
|             self.__flag = True |             self.__flag = True | ||||||
|             self.__cond.notifyAll() |             self.__cond.notifyAll() | ||||||
|  |         finally: | ||||||
|  |             self.__cond.release() | ||||||
| 
 | 
 | ||||||
|     def clear(self): |     def clear(self): | ||||||
|         with self.__cond: |         self.__cond.acquire() | ||||||
|  |         try: | ||||||
|             self.__flag = False |             self.__flag = False | ||||||
|  |         finally: | ||||||
|  |             self.__cond.release() | ||||||
| 
 | 
 | ||||||
|     def wait(self, timeout=None): |     def wait(self, timeout=None): | ||||||
|         with self.__cond: |         self.__cond.acquire() | ||||||
|  |         try: | ||||||
|             if not self.__flag: |             if not self.__flag: | ||||||
|                 self.__cond.wait(timeout) |                 self.__cond.wait(timeout) | ||||||
|  |         finally: | ||||||
|  |             self.__cond.release() | ||||||
| 
 | 
 | ||||||
| # Helper to generate new thread names | # Helper to generate new thread names | ||||||
| _counter = 0 | _counter = 0 | ||||||
|  | @ -525,9 +534,10 @@ def __bootstrap_inner(self): | ||||||
|                     pass |                     pass | ||||||
| 
 | 
 | ||||||
|     def __stop(self): |     def __stop(self): | ||||||
|         with self.__block: |         self.__block.acquire() | ||||||
|             self.__stopped = True |         self.__stopped = True | ||||||
|             self.__block.notifyAll() |         self.__block.notifyAll() | ||||||
|  |         self.__block.release() | ||||||
| 
 | 
 | ||||||
|     def __delete(self): |     def __delete(self): | ||||||
|         "Remove current thread from the dict of currently running threads." |         "Remove current thread from the dict of currently running threads." | ||||||
|  | @ -553,12 +563,15 @@ def __delete(self): | ||||||
|         # since it isn't if dummy_threading is *not* being used then don't |         # since it isn't if dummy_threading is *not* being used then don't | ||||||
|         # hide the exception. |         # hide the exception. | ||||||
| 
 | 
 | ||||||
|         with _active_limbo_lock: |         _active_limbo_lock.acquire() | ||||||
|  |         try: | ||||||
|             try: |             try: | ||||||
|                 del _active[_get_ident()] |                 del _active[_get_ident()] | ||||||
|             except KeyError: |             except KeyError: | ||||||
|                 if 'dummy_threading' not in _sys.modules: |                 if 'dummy_threading' not in _sys.modules: | ||||||
|                     raise |                     raise | ||||||
|  |         finally: | ||||||
|  |             _active_limbo_lock.release() | ||||||
| 
 | 
 | ||||||
|     def join(self, timeout=None): |     def join(self, timeout=None): | ||||||
|         if not self.__initialized: |         if not self.__initialized: | ||||||
|  | @ -571,7 +584,8 @@ def join(self, timeout=None): | ||||||
|         if __debug__: |         if __debug__: | ||||||
|             if not self.__stopped: |             if not self.__stopped: | ||||||
|                 self._note("%s.join(): waiting until thread stops", self) |                 self._note("%s.join(): waiting until thread stops", self) | ||||||
|         with self.__block: |         self.__block.acquire() | ||||||
|  |         try: | ||||||
|             if timeout is None: |             if timeout is None: | ||||||
|                 while not self.__stopped: |                 while not self.__stopped: | ||||||
|                     self.__block.wait() |                     self.__block.wait() | ||||||
|  | @ -589,6 +603,8 @@ def join(self, timeout=None): | ||||||
|                 else: |                 else: | ||||||
|                     if __debug__: |                     if __debug__: | ||||||
|                         self._note("%s.join(): thread stopped", self) |                         self._note("%s.join(): thread stopped", self) | ||||||
|  |         finally: | ||||||
|  |             self.__block.release() | ||||||
| 
 | 
 | ||||||
|     def getName(self): |     def getName(self): | ||||||
|         assert self.__initialized, "Thread.__init__() not called" |         assert self.__initialized, "Thread.__init__() not called" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Raymond Hettinger
						Raymond Hettinger