Hello andreip,
I'd like you to do a code review. Please execute
g4 diff -c 8338509
or point your web browser to
http://mondrian/8338509
to review the following code:
Change 8338509 by [EMAIL PROTECTED] on 2008/09/22 14:10:12 *pending*
Updates mock device data providers to propagate updates without delay.
R=andreip
[EMAIL PROTECTED]
DELTA=23 (7 added, 5 deleted, 11 changed)
OCL=8338509
Affected files ...
...
//depot/googleclient/gears/opensource/gears/geolocation/geolocation_test.cc#23
edit
23 delta lines: 7 added, 5 deleted, 11 changed
Also consider running:
g4 lint -c 8338509
which verifies that the changelist doesn't introduce new style violations.
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [EMAIL PROTECTED]
Change 8338509 by [EMAIL PROTECTED] on 2008/09/22 14:10:12 *pending*
Updates mock device data providers to propagate updates without delay.
Affected files ...
...
//depot/googleclient/gears/opensource/gears/geolocation/geolocation_test.cc#23
edit
====
//depot/googleclient/gears/opensource/gears/geolocation/geolocation_test.cc#23
-
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/geolocation/geolocation_test.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/geolocation_test.cc
2008-09-18 17:05:29.000000000 +0100
+++ googleclient/gears/opensource/gears/geolocation/geolocation_test.cc
2008-09-22 15:01:27.000000000 +0100
@@ -98,11 +98,13 @@
return new MockDeviceDataProviderImpl<DataType>();
}
- MockDeviceDataProviderImpl() {
+ MockDeviceDataProviderImpl()
+ : is_shutting_down_(false) {
Start();
}
virtual ~MockDeviceDataProviderImpl() {
- stop_event_.Signal();
+ is_shutting_down_ = true;
+ event_.Signal();
Join();
}
@@ -117,29 +119,25 @@
static void SetData(const DataType &new_data) {
MutexLock lock(&data_mutex_);
- new_data_ = new_data;
+ data_ = new_data;
+ event_.Signal();
}
private:
// Thread implementation.
virtual void Run() {
- while (!stop_event_.WaitWithTimeout(1000)) {
- data_mutex_.Lock();
- bool new_data_available = !data_.Matches(new_data_);
- if (new_data_available) {
- data_ = new_data_;
- }
- data_mutex_.Unlock();
- if (new_data_available) {
+ while (!is_shutting_down_) {
+ event_.Wait();
+ if (!is_shutting_down_) {
DeviceDataProviderImplBase<DataType>::NotifyListeners();
}
}
}
- Event stop_event_;
-
- DataType data_;
- static DataType new_data_;
+ static Event event_;
+ bool is_shutting_down_;
+
+ static DataType data_;
static Mutex data_mutex_;
DISALLOW_EVIL_CONSTRUCTORS(MockDeviceDataProviderImpl);
@@ -147,7 +145,11 @@
// static
template<typename DataType>
-DataType MockDeviceDataProviderImpl<DataType>::new_data_;
+Event MockDeviceDataProviderImpl<DataType>::event_;
+
+// static
+template<typename DataType>
+DataType MockDeviceDataProviderImpl<DataType>::data_;
// static
template<typename DataType>