mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	gh-111924: Use PyMutex for runtime global locks.
This replaces some usages of PyThread_type_lock with PyMutex, which does not require memory allocation to initialize.
This commit is contained in:
		
							parent
							
								
									974847be44
								
							
						
					
					
						commit
						628f6eb003
					
				
					 18 changed files with 91 additions and 251 deletions
				
			
		|  | @ -1904,7 +1904,7 @@ _PyUnicode_FromId(_Py_Identifier *id) | |||
|     if (index < 0) { | ||||
|         struct _Py_unicode_runtime_ids *rt_ids = &interp->runtime->unicode_state.ids; | ||||
| 
 | ||||
|         PyThread_acquire_lock(rt_ids->lock, WAIT_LOCK); | ||||
|         PyMutex_Lock(&rt_ids->mutex); | ||||
|         // Check again to detect concurrent access. Another thread can have
 | ||||
|         // initialized the index while this thread waited for the lock.
 | ||||
|         index = _Py_atomic_load_ssize(&id->index); | ||||
|  | @ -1914,7 +1914,7 @@ _PyUnicode_FromId(_Py_Identifier *id) | |||
|             rt_ids->next_index++; | ||||
|             _Py_atomic_store_ssize(&id->index, index); | ||||
|         } | ||||
|         PyThread_release_lock(rt_ids->lock); | ||||
|         PyMutex_Unlock(&rt_ids->mutex); | ||||
|     } | ||||
|     assert(index >= 0); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Gross
						Sam Gross