OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 void Worker::PostMessage(std::unique_ptr<SerializationData> data) { | 2427 void Worker::PostMessage(std::unique_ptr<SerializationData> data) { |
2428 in_queue_.Enqueue(std::move(data)); | 2428 in_queue_.Enqueue(std::move(data)); |
2429 in_semaphore_.Signal(); | 2429 in_semaphore_.Signal(); |
2430 } | 2430 } |
2431 | 2431 |
2432 std::unique_ptr<SerializationData> Worker::GetMessage() { | 2432 std::unique_ptr<SerializationData> Worker::GetMessage() { |
2433 std::unique_ptr<SerializationData> result; | 2433 std::unique_ptr<SerializationData> result; |
2434 while (!out_queue_.Dequeue(&result)) { | 2434 while (!out_queue_.Dequeue(&result)) { |
2435 // If the worker is no longer running, and there are no messages in the | 2435 // If the worker is no longer running, and there are no messages in the |
2436 // queue, don't expect any more messages from it. | 2436 // queue, don't expect any more messages from it. |
2437 if (!base::NoBarrier_Load(&running_)) break; | 2437 if (!base::Relaxed_Load(&running_)) break; |
2438 out_semaphore_.Wait(); | 2438 out_semaphore_.Wait(); |
2439 } | 2439 } |
2440 return result; | 2440 return result; |
2441 } | 2441 } |
2442 | 2442 |
2443 | 2443 |
2444 void Worker::Terminate() { | 2444 void Worker::Terminate() { |
2445 base::NoBarrier_Store(&running_, false); | 2445 base::Relaxed_Store(&running_, false); |
2446 // Post NULL to wake the Worker thread message loop, and tell it to stop | 2446 // Post NULL to wake the Worker thread message loop, and tell it to stop |
2447 // running. | 2447 // running. |
2448 PostMessage(NULL); | 2448 PostMessage(NULL); |
2449 } | 2449 } |
2450 | 2450 |
2451 | 2451 |
2452 void Worker::WaitForThread() { | 2452 void Worker::WaitForThread() { |
2453 Terminate(); | 2453 Terminate(); |
2454 thread_->Join(); | 2454 thread_->Join(); |
2455 } | 2455 } |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3192 } | 3192 } |
3193 | 3193 |
3194 } // namespace v8 | 3194 } // namespace v8 |
3195 | 3195 |
3196 | 3196 |
3197 #ifndef GOOGLE3 | 3197 #ifndef GOOGLE3 |
3198 int main(int argc, char* argv[]) { | 3198 int main(int argc, char* argv[]) { |
3199 return v8::Shell::Main(argc, argv); | 3199 return v8::Shell::Main(argc, argv); |
3200 } | 3200 } |
3201 #endif | 3201 #endif |
OLD | NEW |