Merge lp:~knitzsche/scope-aggregator/bug_1489906_thread_safe_buffering into lp:scope-aggregator

Proposed by Kyle Nitzsche
Status: Merged
Approved by: Penk Chen
Approved revision: 147
Merged at revision: 147
Proposed branch: lp:~knitzsche/scope-aggregator/bug_1489906_thread_safe_buffering
Merge into: lp:scope-aggregator
Diff against target: 50 lines (+6/-1)
3 files modified
CMakeLists.txt (+1/-1)
include/resultforwarder.h (+3/-0)
src/resultforwarder.cpp (+2/-0)
To merge this branch: bzr merge lp:~knitzsche/scope-aggregator/bug_1489906_thread_safe_buffering
Reviewer Review Type Date Requested Status
Gary.Wang Approve
Penk Chen Pending
Review via email: mp+269518@code.launchpad.net

Description of the change

This implements thread safety in the buffering code by protecting certain ResultForwarder methods with mutex locks.

To post a comment you must log in.
Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Looks good to me.
Thanks.

review: Approve
Revision history for this message
Penk Chen (penk) wrote :

LGTM, top-approve that

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-08-19 17:53:41 +0000
3+++ CMakeLists.txt 2015-08-28 15:29:00 +0000
4@@ -1,4 +1,4 @@
5-set(VERSION "1.5.25")
6+set(VERSION "1.5.26")
7
8 # Supress qDebug() output
9 ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT )
10
11=== modified file 'include/resultforwarder.h'
12--- include/resultforwarder.h 2015-01-28 08:31:20 +0000
13+++ include/resultforwarder.h 2015-08-28 15:29:00 +0000
14@@ -28,6 +28,7 @@
15 #include<memory>
16 #include<cassert>
17 #include <functional>
18+#include <mutex>
19 #include "notify-strategy.h"
20
21 class ResultForwarder : public unity::scopes::SearchListenerBase {
22@@ -52,6 +53,8 @@
23 virtual void finished(unity::scopes::CompletionDetails const& details) override;
24
25 protected:
26+
27+ std::mutex mutex_;
28 void on_forwarder_ready(ResultForwarder *fw);
29 virtual void on_all_forwarders_ready();
30 unity::scopes::SearchReplyProxy upstream;
31
32=== modified file 'src/resultforwarder.cpp'
33--- src/resultforwarder.cpp 2015-05-22 18:55:44 +0000
34+++ src/resultforwarder.cpp 2015-08-28 15:29:00 +0000
35@@ -34,6 +34,7 @@
36 }
37
38 void ResultForwarder::push(CategorisedResult result) {
39+ std::lock_guard<std::mutex> lock(mutex_);
40 {
41 if (result_filter(result))
42 {
43@@ -59,6 +60,7 @@
44 }
45
46 void ResultForwarder::finished(unity::scopes::CompletionDetails const& /*details*/) {
47+ std::lock_guard<std::mutex> lock(mutex_);
48 if (!ready_)
49 {
50 ready_ = true;

Subscribers

People subscribed via source and target branches