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

Side by Side Diff: third_party/WebKit/Source/wtf/ThreadingWin.cpp

Issue 2394683005: Remove ASSERT_UNUSED (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved. 4 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 return false; 211 return false;
212 } 212 }
213 ++m_mutex.m_recursionCount; 213 ++m_mutex.m_recursionCount;
214 return true; 214 return true;
215 } 215 }
216 216
217 bool PlatformCondition::timedWait(PlatformMutex& mutex, 217 bool PlatformCondition::timedWait(PlatformMutex& mutex,
218 DWORD durationMilliseconds) { 218 DWORD durationMilliseconds) {
219 // Enter the wait state. 219 // Enter the wait state.
220 DWORD res = WaitForSingleObject(m_blockLock, INFINITE); 220 DWORD res = WaitForSingleObject(m_blockLock, INFINITE);
221 ASSERT_UNUSED(res, res == WAIT_OBJECT_0); 221 DCHECK_EQ(res, WAIT_OBJECT_0);
222 ++m_waitersBlocked; 222 ++m_waitersBlocked;
223 res = ReleaseSemaphore(m_blockLock, 1, 0); 223 res = ReleaseSemaphore(m_blockLock, 1, 0);
224 ASSERT_UNUSED(res, res); 224 DCHECK(res);
225 225
226 --mutex.m_recursionCount; 226 --mutex.m_recursionCount;
227 LeaveCriticalSection(&mutex.m_internalMutex); 227 LeaveCriticalSection(&mutex.m_internalMutex);
228 228
229 // Main wait - use timeout. 229 // Main wait - use timeout.
230 bool timedOut = 230 bool timedOut =
231 (WaitForSingleObject(m_blockQueue, durationMilliseconds) == WAIT_TIMEOUT); 231 (WaitForSingleObject(m_blockQueue, durationMilliseconds) == WAIT_TIMEOUT);
232 232
233 res = WaitForSingleObject(m_unblockLock, INFINITE); 233 res = WaitForSingleObject(m_unblockLock, INFINITE);
234 ASSERT_UNUSED(res, res == WAIT_OBJECT_0); 234 DCHECK_EQ(res, WAIT_OBJECT_0);
235 235
236 int signalsLeft = m_waitersToUnblock; 236 int signalsLeft = m_waitersToUnblock;
237 237
238 if (m_waitersToUnblock) { 238 if (m_waitersToUnblock) {
239 --m_waitersToUnblock; 239 --m_waitersToUnblock;
240 } else if (++m_waitersGone == (INT_MAX / 2)) { 240 } else if (++m_waitersGone == (INT_MAX / 2)) {
241 // timeout/canceled or spurious semaphore timeout or spurious wakeup 241 // timeout/canceled or spurious semaphore timeout or spurious wakeup
242 // occured, normalize the m_waitersGone count this may occur if many 242 // occured, normalize the m_waitersGone count this may occur if many
243 // calls to wait with a timeout are made and no call to notify_* is made 243 // calls to wait with a timeout are made and no call to notify_* is made
244 res = WaitForSingleObject(m_blockLock, INFINITE); 244 res = WaitForSingleObject(m_blockLock, INFINITE);
245 ASSERT_UNUSED(res, res == WAIT_OBJECT_0); 245 DCHECK_EQ(res, WAIT_OBJECT_0);
246 m_waitersBlocked -= m_waitersGone; 246 m_waitersBlocked -= m_waitersGone;
247 res = ReleaseSemaphore(m_blockLock, 1, 0); 247 res = ReleaseSemaphore(m_blockLock, 1, 0);
248 ASSERT_UNUSED(res, res); 248 DCHECK(res);
249 m_waitersGone = 0; 249 m_waitersGone = 0;
250 } 250 }
251 251
252 res = ReleaseMutex(m_unblockLock); 252 res = ReleaseMutex(m_unblockLock);
253 ASSERT_UNUSED(res, res); 253 DCHECK(res);
254 254
255 if (signalsLeft == 1) { 255 if (signalsLeft == 1) {
256 res = ReleaseSemaphore(m_blockLock, 1, 0); // Open the gate. 256 res = ReleaseSemaphore(m_blockLock, 1, 0); // Open the gate.
257 ASSERT_UNUSED(res, res); 257 DCHECK(res);
258 } 258 }
259 259
260 EnterCriticalSection(&mutex.m_internalMutex); 260 EnterCriticalSection(&mutex.m_internalMutex);
261 ++mutex.m_recursionCount; 261 ++mutex.m_recursionCount;
262 262
263 return !timedOut; 263 return !timedOut;
264 } 264 }
265 265
266 void PlatformCondition::signal(bool unblockAll) { 266 void PlatformCondition::signal(bool unblockAll) {
267 unsigned signalsToIssue = 0; 267 unsigned signalsToIssue = 0;
268 268
269 DWORD res = WaitForSingleObject(m_unblockLock, INFINITE); 269 DWORD res = WaitForSingleObject(m_unblockLock, INFINITE);
270 ASSERT_UNUSED(res, res == WAIT_OBJECT_0); 270 DCHECK_EQ(res, WAIT_OBJECT_0);
271 271
272 if (m_waitersToUnblock) { // the gate is already closed 272 if (m_waitersToUnblock) { // the gate is already closed
273 if (!m_waitersBlocked) { // no-op 273 if (!m_waitersBlocked) { // no-op
274 res = ReleaseMutex(m_unblockLock); 274 res = ReleaseMutex(m_unblockLock);
275 ASSERT_UNUSED(res, res); 275 DCHECK(res);
276 return; 276 return;
277 } 277 }
278 278
279 if (unblockAll) { 279 if (unblockAll) {
280 signalsToIssue = m_waitersBlocked; 280 signalsToIssue = m_waitersBlocked;
281 m_waitersToUnblock += m_waitersBlocked; 281 m_waitersToUnblock += m_waitersBlocked;
282 m_waitersBlocked = 0; 282 m_waitersBlocked = 0;
283 } else { 283 } else {
284 signalsToIssue = 1; 284 signalsToIssue = 1;
285 ++m_waitersToUnblock; 285 ++m_waitersToUnblock;
286 --m_waitersBlocked; 286 --m_waitersBlocked;
287 } 287 }
288 } else if (m_waitersBlocked > m_waitersGone) { 288 } else if (m_waitersBlocked > m_waitersGone) {
289 res = WaitForSingleObject(m_blockLock, INFINITE); // Close the gate. 289 res = WaitForSingleObject(m_blockLock, INFINITE); // Close the gate.
290 ASSERT_UNUSED(res, res == WAIT_OBJECT_0); 290 DCHECK_EQ(res, WAIT_OBJECT_0);
291 if (m_waitersGone != 0) { 291 if (m_waitersGone != 0) {
292 m_waitersBlocked -= m_waitersGone; 292 m_waitersBlocked -= m_waitersGone;
293 m_waitersGone = 0; 293 m_waitersGone = 0;
294 } 294 }
295 if (unblockAll) { 295 if (unblockAll) {
296 signalsToIssue = m_waitersBlocked; 296 signalsToIssue = m_waitersBlocked;
297 m_waitersToUnblock = m_waitersBlocked; 297 m_waitersToUnblock = m_waitersBlocked;
298 m_waitersBlocked = 0; 298 m_waitersBlocked = 0;
299 } else { 299 } else {
300 signalsToIssue = 1; 300 signalsToIssue = 1;
301 m_waitersToUnblock = 1; 301 m_waitersToUnblock = 1;
302 --m_waitersBlocked; 302 --m_waitersBlocked;
303 } 303 }
304 } else { // No-op. 304 } else { // No-op.
305 res = ReleaseMutex(m_unblockLock); 305 res = ReleaseMutex(m_unblockLock);
306 ASSERT_UNUSED(res, res); 306 DCHECK(res);
307 return; 307 return;
308 } 308 }
309 309
310 res = ReleaseMutex(m_unblockLock); 310 res = ReleaseMutex(m_unblockLock);
311 ASSERT_UNUSED(res, res); 311 DCHECK(res);
312 312
313 if (signalsToIssue) { 313 if (signalsToIssue) {
314 res = ReleaseSemaphore(m_blockQueue, signalsToIssue, 0); 314 res = ReleaseSemaphore(m_blockQueue, signalsToIssue, 0);
315 ASSERT_UNUSED(res, res); 315 DCHECK(res);
316 } 316 }
317 } 317 }
318 318
319 static const long MaxSemaphoreCount = static_cast<long>(~0UL >> 1); 319 static const long MaxSemaphoreCount = static_cast<long>(~0UL >> 1);
320 320
321 ThreadCondition::ThreadCondition() { 321 ThreadCondition::ThreadCondition() {
322 m_condition.m_waitersGone = 0; 322 m_condition.m_waitersGone = 0;
323 m_condition.m_waitersBlocked = 0; 323 m_condition.m_waitersBlocked = 0;
324 m_condition.m_waitersToUnblock = 0; 324 m_condition.m_waitersToUnblock = 0;
325 m_condition.m_blockLock = CreateSemaphore(0, 1, 1, 0); 325 m_condition.m_blockLock = CreateSemaphore(0, 1, 1, 0);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 402 }
403 403
404 void willCreateThread() { 404 void willCreateThread() {
405 s_threadCreated = true; 405 s_threadCreated = true;
406 } 406 }
407 #endif 407 #endif
408 408
409 } // namespace WTF 409 } // namespace WTF
410 410
411 #endif // OS(WIN) 411 #endif // OS(WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698