Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Side by Side Diff: test/cctest/test-libplatform.h

Issue 358363002: Move platform abstraction to base library (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 22 matching lines...) Expand all
33 #include "test/cctest/cctest.h" 33 #include "test/cctest/cctest.h"
34 34
35 using namespace v8::internal; 35 using namespace v8::internal;
36 36
37 class TaskCounter { 37 class TaskCounter {
38 public: 38 public:
39 TaskCounter() : counter_(0) {} 39 TaskCounter() : counter_(0) {}
40 ~TaskCounter() { CHECK_EQ(0, counter_); } 40 ~TaskCounter() { CHECK_EQ(0, counter_); }
41 41
42 int GetCount() const { 42 int GetCount() const {
43 LockGuard<Mutex> guard(&lock_); 43 v8::base::LockGuard<v8::base::Mutex> guard(&lock_);
44 return counter_; 44 return counter_;
45 } 45 }
46 46
47 void Inc() { 47 void Inc() {
48 LockGuard<Mutex> guard(&lock_); 48 v8::base::LockGuard<v8::base::Mutex> guard(&lock_);
49 ++counter_; 49 ++counter_;
50 } 50 }
51 51
52 void Dec() { 52 void Dec() {
53 LockGuard<Mutex> guard(&lock_); 53 v8::base::LockGuard<v8::base::Mutex> guard(&lock_);
54 --counter_; 54 --counter_;
55 } 55 }
56 56
57 private: 57 private:
58 mutable Mutex lock_; 58 mutable v8::base::Mutex lock_;
59 int counter_; 59 int counter_;
60 60
61 DISALLOW_COPY_AND_ASSIGN(TaskCounter); 61 DISALLOW_COPY_AND_ASSIGN(TaskCounter);
62 }; 62 };
63 63
64 64
65 class TestTask : public v8::Task { 65 class TestTask : public v8::Task {
66 public: 66 public:
67 TestTask(TaskCounter* task_counter, bool expected_to_run) 67 TestTask(TaskCounter* task_counter, bool expected_to_run)
68 : task_counter_(task_counter), 68 : task_counter_(task_counter),
(...skipping 17 matching lines...) Expand all
86 86
87 private: 87 private:
88 TaskCounter* task_counter_; 88 TaskCounter* task_counter_;
89 bool expected_to_run_; 89 bool expected_to_run_;
90 bool executed_; 90 bool executed_;
91 91
92 DISALLOW_COPY_AND_ASSIGN(TestTask); 92 DISALLOW_COPY_AND_ASSIGN(TestTask);
93 }; 93 };
94 94
95 95
96 class TestWorkerThread : public Thread { 96 class TestWorkerThread : public v8::base::Thread {
97 public: 97 public:
98 explicit TestWorkerThread(v8::Task* task) 98 explicit TestWorkerThread(v8::Task* task)
99 : Thread("libplatform TestWorkerThread"), semaphore_(0), task_(task) {} 99 : Thread("libplatform TestWorkerThread"), semaphore_(0), task_(task) {}
100 virtual ~TestWorkerThread() {} 100 virtual ~TestWorkerThread() {}
101 101
102 void Signal() { semaphore_.Signal(); } 102 void Signal() { semaphore_.Signal(); }
103 103
104 // Thread implementation. 104 // Thread implementation.
105 virtual void Run() V8_OVERRIDE { 105 virtual void Run() V8_OVERRIDE {
106 semaphore_.Wait(); 106 semaphore_.Wait();
107 if (task_) { 107 if (task_) {
108 task_->Run(); 108 task_->Run();
109 delete task_; 109 delete task_;
110 } 110 }
111 } 111 }
112 112
113 private: 113 private:
114 Semaphore semaphore_; 114 v8::base::Semaphore semaphore_;
115 v8::Task* task_; 115 v8::Task* task_;
116 116
117 DISALLOW_COPY_AND_ASSIGN(TestWorkerThread); 117 DISALLOW_COPY_AND_ASSIGN(TestWorkerThread);
118 }; 118 };
119 119
120 #endif // TEST_LIBPLATFORM_H_ 120 #endif // TEST_LIBPLATFORM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698