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

Unified Diff: src/libplatform/task-queue.cc

Issue 104583003: [platform] Implement a worker pool (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/libplatform/task-queue.h ('k') | src/libplatform/worker-thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/libplatform/task-queue.cc
diff --git a/src/hydrogen-infer-types.h b/src/libplatform/task-queue.cc
similarity index 63%
copy from src/hydrogen-infer-types.h
copy to src/libplatform/task-queue.cc
index cfcbf3549ba51603ea9f8aabd55f4d6070ad0488..1ea31eb26e0aa700944fa9927e460ef73b5ae9fa 100644
--- a/src/hydrogen-infer-types.h
+++ b/src/libplatform/task-queue.cc
@@ -25,35 +25,56 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef V8_HYDROGEN_INFER_TYPES_H_
-#define V8_HYDROGEN_INFER_TYPES_H_
+#include "task-queue.h"
-#include "hydrogen.h"
+// TODO(jochen): We should have our own version of checks.h.
+#include "../checks.h"
namespace v8 {
namespace internal {
+TaskQueue::TaskQueue() : process_queue_semaphore_(0), terminated_(false) {}
-class HInferTypesPhase : public HPhase {
- public:
- explicit HInferTypesPhase(HGraph* graph)
- : HPhase("H_Inferring types", graph), worklist_(8, zone()),
- in_worklist_(graph->GetMaximumValueID(), zone()) { }
- void Run() {
- InferTypes(0, graph()->blocks()->length() - 1);
- }
+TaskQueue::~TaskQueue() {
+ LockGuard<Mutex> guard(&lock_);
+ ASSERT(terminated_);
+ ASSERT(task_queue_.empty());
+}
- private:
- void InferTypes(int from_inclusive, int to_inclusive);
- ZoneList<HValue*> worklist_;
- BitVector in_worklist_;
+void TaskQueue::Append(Task* task) {
+ LockGuard<Mutex> guard(&lock_);
+ ASSERT(!terminated_);
+ task_queue_.push(task);
+ process_queue_semaphore_.Signal();
+}
- DISALLOW_COPY_AND_ASSIGN(HInferTypesPhase);
-};
+Task* TaskQueue::GetNext() {
+ for (;;) {
+ {
+ LockGuard<Mutex> guard(&lock_);
+ if (!task_queue_.empty()) {
+ Task* result = task_queue_.front();
+ task_queue_.pop();
+ return result;
+ }
+ if (terminated_) {
+ process_queue_semaphore_.Signal();
+ return NULL;
+ }
+ }
+ process_queue_semaphore_.Wait();
+ }
+}
-} } // namespace v8::internal
-#endif // V8_HYDROGEN_INFER_TYPES_H_
+void TaskQueue::Terminate() {
+ LockGuard<Mutex> guard(&lock_);
+ ASSERT(!terminated_);
+ terminated_ = true;
+ process_queue_semaphore_.Signal();
+}
+
+} } // namespace v8::internal
« no previous file with comments | « src/libplatform/task-queue.h ('k') | src/libplatform/worker-thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698