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

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

Issue 157503002: A64: Synchronize with r18444. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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
« 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/extensions/free-buffer-extension.cc b/src/libplatform/task-queue.cc
similarity index 63%
copy from src/extensions/free-buffer-extension.cc
copy to src/libplatform/task-queue.cc
index 5cf2b68146c9d325096b6f94172bca55d498c2fa..1ea31eb26e0aa700944fa9927e460ef73b5ae9fa 100644
--- a/src/extensions/free-buffer-extension.cc
+++ b/src/libplatform/task-queue.cc
@@ -25,36 +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.
-#include "free-buffer-extension.h"
-#include "platform.h"
-#include "v8.h"
+#include "task-queue.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) {}
+
-v8::Handle<v8::FunctionTemplate> FreeBufferExtension::GetNativeFunctionTemplate(
- v8::Isolate* isolate,
- v8::Handle<v8::String> str) {
- return v8::FunctionTemplate::New(FreeBufferExtension::FreeBuffer);
+TaskQueue::~TaskQueue() {
+ LockGuard<Mutex> guard(&lock_);
+ ASSERT(terminated_);
+ ASSERT(task_queue_.empty());
}
-void FreeBufferExtension::FreeBuffer(
- const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::Handle<v8::ArrayBuffer> arrayBuffer = args[0].As<v8::ArrayBuffer>();
- v8::ArrayBuffer::Contents contents = arrayBuffer->Externalize();
- V8::ArrayBufferAllocator()->Free(contents.Data(), contents.ByteLength());
+void TaskQueue::Append(Task* task) {
+ LockGuard<Mutex> guard(&lock_);
+ ASSERT(!terminated_);
+ task_queue_.push(task);
+ process_queue_semaphore_.Signal();
}
-void FreeBufferExtension::Register() {
- static char buffer[100];
- Vector<char> temp_vector(buffer, sizeof(buffer));
- OS::SNPrintF(temp_vector, "native function freeBuffer();");
+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();
+ }
+}
+
- static FreeBufferExtension buffer_free_extension(buffer);
- static v8::DeclareExtension declaration(&buffer_free_extension);
+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