Mercurial > dwindows
comparison android/dw.cpp @ 2632:04d5c8147e33
Android: mainSleep seems to be hanging, so switch to using dw_mutex_trylock()
in the event queue so it does not call mainSleep if it is already locked.
This mutex is only used to manage access to the event queue, so we don't
need to make sure the UI is accessible during this time.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 03 Aug 2021 19:48:02 +0000 |
parents | e9f4f0d2e5da |
children | 3d20fcfd8583 |
comparison
equal
deleted
inserted
replaced
2631:e9f4f0d2e5da | 2632:04d5c8147e33 |
---|---|
480 int retval = FALSE; | 480 int retval = FALSE; |
481 | 481 |
482 /* Initialize the mutex if necessary... return on failure. */ | 482 /* Initialize the mutex if necessary... return on failure. */ |
483 if(!_dw_event_mutex && !(_dw_event_mutex = dw_mutex_new())) | 483 if(!_dw_event_mutex && !(_dw_event_mutex = dw_mutex_new())) |
484 return retval; | 484 return retval; |
485 | |
485 /* Protect the queue in a mutex... hold for as short as possible */ | 486 /* Protect the queue in a mutex... hold for as short as possible */ |
486 dw_mutex_lock(_dw_event_mutex); | 487 while(dw_mutex_trylock(_dw_event_mutex) != DW_ERROR_NONE) |
488 sched_yield(); | |
489 | |
487 /* If we are at the end of the queue, loop back to the start. */ | 490 /* If we are at the end of the queue, loop back to the start. */ |
488 if(newtail >= _DW_EVENT_QUEUE_LENGTH) | 491 if(newtail >= _DW_EVENT_QUEUE_LENGTH) |
489 newtail = 0; | 492 newtail = 0; |
490 /* If the new tail will be at the head, the event queue | 493 /* If the new tail will be at the head, the event queue |
491 * if full... drop the event. | 494 * if full... drop the event. |