Mercurial > dwindows
changeset 693:2f21ee9d7c7b
Experimental change for locking on the main thread... will be committing
dw_main_* updates momentarily to go along with this.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 10 Mar 2011 18:30:03 +0000 |
parents | bd909322f40d |
children | 130ca42c4ae3 |
files | mac/dw.m |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mac/dw.m Thu Mar 10 02:34:14 2011 +0000 +++ b/mac/dw.m Thu Mar 10 18:30:03 2011 +0000 @@ -6466,19 +6466,23 @@ */ void dw_mutex_lock(HMTX mutex) { - DWTID saved = (DWTID)-1; - + /* We need to handle locks from the main thread differently... + * since we can't stop message processing... otherwise we + * will deadlock... so try to acquire the lock and continue + * processing messages in between tries. + */ if(DWThread == pthread_self()) { - saved = DWThread; - DWThread = (DWTID)-1; pthread_mutex_unlock(DWRunMutex); + while(pthread_mutex_trylock(mutex) != 0) + { + dw_main_iteration(); + } + pthread_mutex_lock(DWRunMutex); } - pthread_mutex_lock(mutex); - if(saved != (DWTID)-1) + else { - DWThread = saved; - pthread_mutex_lock(DWRunMutex); + pthread_mutex_lock(mutex); } }