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

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

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/default-platform.cc ('k') | src/libplatform/task-queue.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/libplatform/task-queue.h
diff --git a/src/hydrogen-minus-zero.h b/src/libplatform/task-queue.h
similarity index 68%
copy from src/hydrogen-minus-zero.h
copy to src/libplatform/task-queue.h
index d23ec1196b3419cdc06e20aa3e12688979306009..a3182d35311febb984922a8c38ad0730441806d8 100644
--- a/src/hydrogen-minus-zero.h
+++ b/src/libplatform/task-queue.h
@@ -25,32 +25,47 @@
// (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_MINUS_ZERO_H_
-#define V8_HYDROGEN_MINUS_ZERO_H_
+#ifndef V8_LIBPLATFORM_TASK_QUEUE_H_
+#define V8_LIBPLATFORM_TASK_QUEUE_H_
-#include "hydrogen.h"
+#include <queue>
+
+// TODO(jochen): We should have our own version of globals.h.
+#include "../globals.h"
+#include "../platform/mutex.h"
+#include "../platform/semaphore.h"
namespace v8 {
-namespace internal {
+class Task;
-class HComputeMinusZeroChecksPhase : public HPhase {
+namespace internal {
+
+class TaskQueue {
public:
- explicit HComputeMinusZeroChecksPhase(HGraph* graph)
- : HPhase("H_Compute minus zero checks", graph),
- visited_(graph->GetMaximumValueID(), zone()) { }
+ TaskQueue();
+ ~TaskQueue();
- void Run();
+ // Appends a task to the queue. The queue takes ownership of |task|.
+ void Append(Task* task);
- private:
- void PropagateMinusZeroChecks(HValue* value);
+ // Returns the next task to process. Blocks if no task is available. Returns
+ // NULL if the queue is terminated.
+ Task* GetNext();
- BitVector visited_;
+ // Terminate the queue.
+ void Terminate();
- DISALLOW_COPY_AND_ASSIGN(HComputeMinusZeroChecksPhase);
-};
+ private:
+ Mutex lock_;
+ Semaphore process_queue_semaphore_;
+ std::queue<Task*> task_queue_;
+ bool terminated_;
+ DISALLOW_COPY_AND_ASSIGN(TaskQueue);
+};
} } // namespace v8::internal
-#endif // V8_HYDROGEN_MINUS_ZERO_H_
+
+#endif // V8_LIBPLATFORM_TASK_QUEUE_H_
« no previous file with comments | « src/libplatform/default-platform.cc ('k') | src/libplatform/task-queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698