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

Unified Diff: src/background-parser-thread.h

Issue 366153002: Add script streaming API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: special chars fix Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/background-parser-thread.h
diff --git a/src/background-parser-thread.h b/src/background-parser-thread.h
new file mode 100644
index 0000000000000000000000000000000000000000..a4b0bf768e6eada5e4b541e89bf4ed85e0b30a0f
--- /dev/null
+++ b/src/background-parser-thread.h
@@ -0,0 +1,64 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_BACKGROUND_PARSER_THREAD_H_
+#define V8_BACKGROUND_PARSER_THREAD_H_
+
+#include "src/base/platform/platform.h"
+#include "src/base/platform/semaphore.h"
+#include "src/compiler.h"
+
+namespace v8 {
+namespace internal {
+
+class BackgroundParsingTask {
+ public:
+ BackgroundParsingTask(ScriptCompiler::StreamedSource* source,
+ ScriptCompiler::StreamingCompleteCallback callback,
+ void* callback_data, bool allow_lazy, Isolate* isolate)
+ : source_(source),
+ callback_(callback),
+ callback_data_(callback_data),
+ script_data_(NULL),
+ hash_seed_(isolate->heap()->HashSeed()),
+ allow_lazy_(allow_lazy),
+ isolate_(isolate) {}
+
+ void Run();
+
+ private:
+ friend class v8::ScriptCompiler;
+
+ ScriptCompiler::StreamedSource* source_;
+ ScriptCompiler::StreamingCompleteCallback callback_;
+ void* callback_data_;
+ ScriptData* script_data_;
+ uint32_t hash_seed_;
+ bool allow_lazy_;
+ Isolate* isolate_;
+};
+
+
+// For compiling on the background.
+class BackgroundParserThread : public base::Thread {
+ public:
+ BackgroundParserThread();
+
+ virtual void Run();
+
+ void Stop();
+ // This can only be called after the previous task has finished.
+ void SetTask(BackgroundParsingTask* task);
+
+ bool HasTask() const { return task_ != NULL; }
+
+ private:
+ BackgroundParsingTask* task_;
+ base::Semaphore have_work_;
+ bool should_stop_;
+};
+}
+} // namespace v8::internal
+
+#endif // V8_BACKGROUND_PARSER_THREAD_H_
« include/v8.h ('K') | « src/api.cc ('k') | src/background-parser-thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698