OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 bool* done_; | 60 bool* done_; |
61 }; | 61 }; |
62 | 62 |
63 class ReadTask : public SharedExclusiveTask { | 63 class ReadTask : public SharedExclusiveTask { |
64 public: | 64 public: |
65 ReadTask(SharedExclusiveLock* shared_exclusive_lock, int* value, bool* done) | 65 ReadTask(SharedExclusiveLock* shared_exclusive_lock, int* value, bool* done) |
66 : SharedExclusiveTask(shared_exclusive_lock, value, done) { | 66 : SharedExclusiveTask(shared_exclusive_lock, value, done) { |
67 } | 67 } |
68 | 68 |
69 void PostRead(int* value) { | 69 void PostRead(int* value) { |
70 worker_thread_->Post(this, kMsgRead, new TypedMessageData<int*>(value)); | 70 worker_thread_->Post(RTC_FROM_HERE, this, kMsgRead, |
| 71 new TypedMessageData<int*>(value)); |
71 } | 72 } |
72 | 73 |
73 private: | 74 private: |
74 virtual void OnMessage(Message* message) { | 75 virtual void OnMessage(Message* message) { |
75 ASSERT(rtc::Thread::Current() == worker_thread_.get()); | 76 ASSERT(rtc::Thread::Current() == worker_thread_.get()); |
76 ASSERT(message != NULL); | 77 ASSERT(message != NULL); |
77 ASSERT(message->message_id == kMsgRead); | 78 ASSERT(message->message_id == kMsgRead); |
78 | 79 |
79 TypedMessageData<int*>* message_data = | 80 TypedMessageData<int*>* message_data = |
80 static_cast<TypedMessageData<int*>*>(message->pdata); | 81 static_cast<TypedMessageData<int*>*>(message->pdata); |
(...skipping 12 matching lines...) Expand all Loading... |
93 } | 94 } |
94 }; | 95 }; |
95 | 96 |
96 class WriteTask : public SharedExclusiveTask { | 97 class WriteTask : public SharedExclusiveTask { |
97 public: | 98 public: |
98 WriteTask(SharedExclusiveLock* shared_exclusive_lock, int* value, bool* done) | 99 WriteTask(SharedExclusiveLock* shared_exclusive_lock, int* value, bool* done) |
99 : SharedExclusiveTask(shared_exclusive_lock, value, done) { | 100 : SharedExclusiveTask(shared_exclusive_lock, value, done) { |
100 } | 101 } |
101 | 102 |
102 void PostWrite(int value) { | 103 void PostWrite(int value) { |
103 worker_thread_->Post(this, kMsgWrite, new TypedMessageData<int>(value)); | 104 worker_thread_->Post(RTC_FROM_HERE, this, kMsgWrite, |
| 105 new TypedMessageData<int>(value)); |
104 } | 106 } |
105 | 107 |
106 private: | 108 private: |
107 virtual void OnMessage(Message* message) { | 109 virtual void OnMessage(Message* message) { |
108 ASSERT(rtc::Thread::Current() == worker_thread_.get()); | 110 ASSERT(rtc::Thread::Current() == worker_thread_.get()); |
109 ASSERT(message != NULL); | 111 ASSERT(message != NULL); |
110 ASSERT(message->message_id == kMsgWrite); | 112 ASSERT(message->message_id == kMsgWrite); |
111 | 113 |
112 TypedMessageData<int>* message_data = | 114 TypedMessageData<int>* message_data = |
113 static_cast<TypedMessageData<int>*>(message->pdata); | 115 static_cast<TypedMessageData<int>*>(message->pdata); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 Thread::SleepMs(kProcessTimeInMs); | 222 Thread::SleepMs(kProcessTimeInMs); |
221 EXPECT_EQ(1, value_); | 223 EXPECT_EQ(1, value_); |
222 } | 224 } |
223 | 225 |
224 EXPECT_TRUE_WAIT(done, kProcessTimeoutInMs); | 226 EXPECT_TRUE_WAIT(done, kProcessTimeoutInMs); |
225 EXPECT_EQ(2, value_); | 227 EXPECT_EQ(2, value_); |
226 EXPECT_GE(writer.waiting_time_in_ms(), kWaitThresholdInMs); | 228 EXPECT_GE(writer.waiting_time_in_ms(), kWaitThresholdInMs); |
227 } | 229 } |
228 | 230 |
229 } // namespace rtc | 231 } // namespace rtc |
OLD | NEW |