[baobab/wip/vala: 12/45] threaded scanner: use an asyncqueue
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala: 12/45] threaded scanner: use an asyncqueue
- Date: Sun, 29 Jan 2012 14:44:35 +0000 (UTC)
commit 40959f5f2b5000eecf1c7a4bd9efecc1585efa1a
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Jan 5 19:36:05 2012 -0500
threaded scanner: use an asyncqueue
instead of using a GQueue and separate mutex
src/baobab-threaded-scanner.vala | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/src/baobab-threaded-scanner.vala b/src/baobab-threaded-scanner.vala
index 70bfd46..abebf3b 100644
--- a/src/baobab-threaded-scanner.vala
+++ b/src/baobab-threaded-scanner.vala
@@ -1,8 +1,7 @@
namespace Baobab {
class ThreadedScanner : Scanner {
- Queue<ResultsArray> results_queue;
+ AsyncQueue<ResultsArray> results_queue;
ThreadedScanner? self;
- Mutex mutex;
File directory;
@@ -111,9 +110,7 @@ namespace Baobab {
child_results.percent = 100 * ((double) child_results.size) / ((double) results.size);
}
- mutex.lock ();
- results_queue.push_tail ((owned) results_array);
- mutex.unlock ();
+ results_queue.push ((owned) results_array);
return results;
}
@@ -158,9 +155,7 @@ namespace Baobab {
bool process_results () {
while (true) {
- mutex.lock ();
- var results_array = results_queue.pop_head ();
- mutex.unlock ();
+ var results_array = results_queue.try_pop ();
if (results_array == null) {
break;
@@ -201,8 +196,7 @@ namespace Baobab {
}
public ThreadedScanner () {
- results_queue = new Queue<ResultsArray> ();
- mutex = new Mutex ();
+ results_queue = new AsyncQueue<ResultsArray> ();
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]