[shotwell/wip/742047-mutex] Possible fix
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/742047-mutex] Possible fix
- Date: Mon, 29 Dec 2014 22:54:46 +0000 (UTC)
commit 3482a3c5112c8cada8ef9ad8ce6d7e0f17ee6967
Author: Jim Nelson <jim yorba org>
Date: Mon Dec 29 14:53:54 2014 -0800
Possible fix
As with Geary, unlock the mutex and yield a bit of time to allow
background thread a window to notify.
src/threads/Semaphore.vala | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/threads/Semaphore.vala b/src/threads/Semaphore.vala
index dfb0a2f..c5a6b1b 100644
--- a/src/threads/Semaphore.vala
+++ b/src/threads/Semaphore.vala
@@ -66,8 +66,14 @@ public abstract class AbstractSemaphore {
public void wait() {
mutex.lock();
- while (do_wait() == WaitAction.SLEEP)
+ while (do_wait() == WaitAction.SLEEP) {
+ // release the mutex and yield to give other threads a chance to notify
+ mutex.unlock();
+ Thread.yield();
+ mutex.lock();
+
monitor.wait(mutex);
+ }
mutex.unlock();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]