| 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_
|
|
|