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

Side by Side Diff: Source/core/workers/WorkerRunLoop.cpp

Issue 15338009: Move workers to Chromium threading (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revert actual model change Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/workers/WorkerMessagingProxy.cpp ('k') | Source/core/workers/WorkerThread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 RunLoopSetup setup(*this); 140 RunLoopSetup setup(*this);
141 ModePredicate modePredicate(mode); 141 ModePredicate modePredicate(mode);
142 MessageQueueWaitResult result = runInMode(context, modePredicate, waitMode); 142 MessageQueueWaitResult result = runInMode(context, modePredicate, waitMode);
143 return result; 143 return result;
144 } 144 }
145 145
146 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerContext* context, const Mo dePredicate& predicate, WaitMode waitMode) 146 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerContext* context, const Mo dePredicate& predicate, WaitMode waitMode)
147 { 147 {
148 ASSERT(context); 148 ASSERT(context);
149 ASSERT(context->thread()); 149 ASSERT(context->thread());
150 ASSERT(context->thread()->threadID() == currentThread()); 150 ASSERT(context->thread()->isCurrentThread());
151 151
152 double absoluteTime = 0.0; 152 double absoluteTime = 0.0;
153 if (waitMode == WaitForMessage) 153 if (waitMode == WaitForMessage)
154 absoluteTime = (predicate.isDefaultMode() && m_sharedTimer->isActive()) ? m_sharedTimer->fireTime() : MessageQueue<Task>::infiniteTime(); 154 absoluteTime = (predicate.isDefaultMode() && m_sharedTimer->isActive()) ? m_sharedTimer->fireTime() : MessageQueue<Task>::infiniteTime();
155 MessageQueueWaitResult result; 155 MessageQueueWaitResult result;
156 OwnPtr<WorkerRunLoop::Task> task = m_messageQueue.waitForMessageFilteredWith Timeout(result, predicate, absoluteTime); 156 OwnPtr<WorkerRunLoop::Task> task = m_messageQueue.waitForMessageFilteredWith Timeout(result, predicate, absoluteTime);
157 157
158 // If the context is closing, don't execute any further JavaScript tasks (pe r section 4.1.1 of the Web Workers spec). However, there may be implementation cleanup tasks in the queue, so keep running through it. 158 // If the context is closing, don't execute any further JavaScript tasks (pe r section 4.1.1 of the Web Workers spec). However, there may be implementation cleanup tasks in the queue, so keep running through it.
159 159
160 switch (result) { 160 switch (result) {
(...skipping 10 matching lines...) Expand all
171 break; 171 break;
172 } 172 }
173 173
174 return result; 174 return result;
175 } 175 }
176 176
177 void WorkerRunLoop::runCleanupTasks(WorkerContext* context) 177 void WorkerRunLoop::runCleanupTasks(WorkerContext* context)
178 { 178 {
179 ASSERT(context); 179 ASSERT(context);
180 ASSERT(context->thread()); 180 ASSERT(context->thread());
181 ASSERT(context->thread()->threadID() == currentThread()); 181 ASSERT(context->thread()->isCurrentThread());
182 ASSERT(m_messageQueue.killed()); 182 ASSERT(m_messageQueue.killed());
183 183
184 while (true) { 184 while (true) {
185 OwnPtr<WorkerRunLoop::Task> task = m_messageQueue.tryGetMessageIgnoringK illed(); 185 OwnPtr<WorkerRunLoop::Task> task = m_messageQueue.tryGetMessageIgnoringK illed();
186 if (!task) 186 if (!task)
187 return; 187 return;
188 task->performTask(*this, context); 188 task->performTask(*this, context);
189 } 189 }
190 } 190 }
191 191
(...skipping 29 matching lines...) Expand all
221 m_task->performTask(context); 221 m_task->performTask(context);
222 } 222 }
223 223
224 WorkerRunLoop::Task::Task(PassOwnPtr<ScriptExecutionContext::Task> task, const S tring& mode) 224 WorkerRunLoop::Task::Task(PassOwnPtr<ScriptExecutionContext::Task> task, const S tring& mode)
225 : m_task(task) 225 : m_task(task)
226 , m_mode(mode.isolatedCopy()) 226 , m_mode(mode.isolatedCopy())
227 { 227 {
228 } 228 }
229 229
230 } // namespace WebCore 230 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerMessagingProxy.cpp ('k') | Source/core/workers/WorkerThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698