changeset 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
files android/dw.cpp
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/android/dw.cpp	Mon Aug 02 20:37:56 2021 +0000
+++ b/android/dw.cpp	Tue Aug 03 19:48:02 2021 +0000
@@ -482,8 +482,11 @@
     /* Initialize the mutex if necessary... return on failure. */
     if(!_dw_event_mutex && !(_dw_event_mutex = dw_mutex_new()))
         return retval;
+
     /* Protect the queue in a mutex... hold for as short as possible */
-    dw_mutex_lock(_dw_event_mutex);
+    while(dw_mutex_trylock(_dw_event_mutex) != DW_ERROR_NONE)
+        sched_yield();
+
     /* If we are at the end of the queue, loop back to the start. */
     if(newtail >= _DW_EVENT_QUEUE_LENGTH)
         newtail = 0;