[f-spot] Avoid busy waiting for database queries.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot] Avoid busy waiting for database queries.
- Date: Fri, 14 May 2010 17:18:25 +0000 (UTC)
commit 89e6e0236bd615cc0327610e37d3e57e32f73524
Author: Michal Nánási <mic gnome ksp sk>
Date: Fri May 14 19:14:13 2010 +0200
Avoid busy waiting for database queries.
Fixes BGO 614403 - Busy wait
src/QueuedSqliteDatabase.cs | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/QueuedSqliteDatabase.cs b/src/QueuedSqliteDatabase.cs
index b8374af..86a387c 100644
--- a/src/QueuedSqliteDatabase.cs
+++ b/src/QueuedSqliteDatabase.cs
@@ -343,6 +343,7 @@ namespace Banshee.Database
private int insert_id;
private Exception execution_exception;
private bool finished = false;
+ private Object finishedLock = new Object();
private SqliteCommand command;
@@ -397,12 +398,19 @@ namespace Banshee.Database
}
command.Dispose();
+ Monitor.Enter(finishedLock);
finished = true;
+ Monitor.Pulse(finishedLock);
+ Monitor.Exit(finishedLock);
}
public object WaitForResult()
{
- while(!finished);
+ Monitor.Enter(finishedLock);
+ while (!finished) {
+ Monitor.Wait(finishedLock);
+ };
+ Monitor.Exit(finishedLock);
if(execution_exception != null) {
throw execution_exception;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]