Lines Matching refs:queue

259   WorkQueue queue(kThreadCount);  // Start the threads.  in TEST_F()  local
266 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
267 while (!queue.EveryIdWasAllocated()) in TEST_F()
268 queue.all_threads_have_ids()->Wait(); in TEST_F()
273 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
277 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
278 EXPECT_EQ(0, queue.GetNumThreadsTakingAssignments()); in TEST_F()
279 EXPECT_EQ(0, queue.GetNumThreadsCompletingTasks()); in TEST_F()
280 EXPECT_EQ(0, queue.task_count()); in TEST_F()
281 EXPECT_EQ(0, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
282 EXPECT_EQ(0, queue.GetMinCompletionsByWorkerThread()); in TEST_F()
283 EXPECT_EQ(0, queue.GetNumberOfCompletedTasks()); in TEST_F()
287 queue.ResetHistory(); in TEST_F()
288 queue.SetTaskCount(kTaskCount); in TEST_F()
289 queue.SetWorkTime(kThirtyMs); in TEST_F()
290 queue.SetAllowHelp(true); in TEST_F()
295 queue.work_is_available()->Signal(); // But each worker can signal another. in TEST_F()
297 queue.SpinUntilTaskCountLessThan(kTaskCount); in TEST_F()
299 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
303 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
304 while (queue.task_count()) in TEST_F()
305 queue.no_more_tasks()->Wait(); in TEST_F()
310 EXPECT_LE(2, queue.GetNumThreadsTakingAssignments()); in TEST_F()
311 EXPECT_EQ(kTaskCount, queue.GetNumberOfCompletedTasks()); in TEST_F()
314 queue.ResetHistory(); in TEST_F()
315 queue.SetTaskCount(3); in TEST_F()
316 queue.SetWorkTime(kThirtyMs); in TEST_F()
317 queue.SetAllowHelp(false); in TEST_F()
319 queue.work_is_available()->Broadcast(); // Make them all try. in TEST_F()
321 queue.SpinUntilTaskCountLessThan(3); in TEST_F()
323 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
326 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
327 EXPECT_EQ(3, queue.GetNumThreadsTakingAssignments()); in TEST_F()
328 EXPECT_EQ(3, queue.GetNumThreadsCompletingTasks()); in TEST_F()
329 EXPECT_EQ(0, queue.task_count()); in TEST_F()
330 EXPECT_EQ(1, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
331 EXPECT_EQ(0, queue.GetMinCompletionsByWorkerThread()); in TEST_F()
332 EXPECT_EQ(3, queue.GetNumberOfCompletedTasks()); in TEST_F()
335 queue.ResetHistory(); in TEST_F()
336 queue.SetTaskCount(3); in TEST_F()
337 queue.SetWorkTime(kThirtyMs); in TEST_F()
338 queue.SetAllowHelp(true); // Allow (unnecessary) help requests. in TEST_F()
340 queue.work_is_available()->Broadcast(); // Signal all threads. in TEST_F()
342 queue.SpinUntilTaskCountLessThan(3); in TEST_F()
344 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
347 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
348 EXPECT_EQ(3, queue.GetNumThreadsTakingAssignments()); in TEST_F()
349 EXPECT_EQ(3, queue.GetNumThreadsCompletingTasks()); in TEST_F()
350 EXPECT_EQ(0, queue.task_count()); in TEST_F()
351 EXPECT_EQ(1, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
352 EXPECT_EQ(0, queue.GetMinCompletionsByWorkerThread()); in TEST_F()
353 EXPECT_EQ(3, queue.GetNumberOfCompletedTasks()); in TEST_F()
356 queue.ResetHistory(); in TEST_F()
357 queue.SetTaskCount(20); // 2 tasks per thread. in TEST_F()
358 queue.SetWorkTime(kThirtyMs); in TEST_F()
359 queue.SetAllowHelp(true); in TEST_F()
361 queue.work_is_available()->Signal(); // But each worker can signal another. in TEST_F()
363 queue.SpinUntilTaskCountLessThan(20); in TEST_F()
365 queue.SpinUntilAllThreadsAreWaiting(); // Should take about 60 ms. in TEST_F()
368 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
369 EXPECT_EQ(10, queue.GetNumThreadsTakingAssignments()); in TEST_F()
370 EXPECT_EQ(10, queue.GetNumThreadsCompletingTasks()); in TEST_F()
371 EXPECT_EQ(0, queue.task_count()); in TEST_F()
372 EXPECT_EQ(20, queue.GetNumberOfCompletedTasks()); in TEST_F()
375 queue.ResetHistory(); in TEST_F()
376 queue.SetTaskCount(20); // 2 tasks per thread. in TEST_F()
377 queue.SetWorkTime(kThirtyMs); in TEST_F()
378 queue.SetAllowHelp(true); in TEST_F()
380 queue.work_is_available()->Broadcast(); in TEST_F()
382 queue.SpinUntilTaskCountLessThan(20); in TEST_F()
384 queue.SpinUntilAllThreadsAreWaiting(); // Should take about 60 ms. in TEST_F()
387 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
388 EXPECT_EQ(10, queue.GetNumThreadsTakingAssignments()); in TEST_F()
389 EXPECT_EQ(10, queue.GetNumThreadsCompletingTasks()); in TEST_F()
390 EXPECT_EQ(0, queue.task_count()); in TEST_F()
391 EXPECT_EQ(20, queue.GetNumberOfCompletedTasks()); in TEST_F()
393 queue.SetShutdown(); in TEST_F()
395 queue.work_is_available()->Broadcast(); // Force check for shutdown. in TEST_F()
398 queue.ThreadSafeCheckShutdown(kThreadCount)); in TEST_F()
409 WorkQueue queue(kThreadCount); // Start the threads. in TEST_F() local
416 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
417 while (!queue.EveryIdWasAllocated()) in TEST_F()
418 queue.all_threads_have_ids()->Wait(); in TEST_F()
422 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
426 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
427 EXPECT_EQ(0, queue.GetNumThreadsTakingAssignments()); in TEST_F()
428 EXPECT_EQ(0, queue.GetNumThreadsCompletingTasks()); in TEST_F()
429 EXPECT_EQ(0, queue.task_count()); in TEST_F()
430 EXPECT_EQ(0, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
431 EXPECT_EQ(0, queue.GetMinCompletionsByWorkerThread()); in TEST_F()
432 EXPECT_EQ(0, queue.GetNumberOfCompletedTasks()); in TEST_F()
435 queue.ResetHistory(); in TEST_F()
436 queue.SetTaskCount(20 * kThreadCount); in TEST_F()
437 queue.SetWorkTime(kFortyFiveMs); in TEST_F()
438 queue.SetAllowHelp(false); in TEST_F()
440 queue.work_is_available()->Broadcast(); // Start up all threads. in TEST_F()
443 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
444 while (queue.task_count() != 0) in TEST_F()
445 queue.no_more_tasks()->Wait(); in TEST_F()
449 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
454 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
455 EXPECT_EQ(kThreadCount, queue.GetNumThreadsTakingAssignments()); in TEST_F()
456 EXPECT_EQ(kThreadCount, queue.GetNumThreadsCompletingTasks()); in TEST_F()
457 EXPECT_EQ(0, queue.task_count()); in TEST_F()
458 EXPECT_LE(20, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
459 EXPECT_EQ(20 * kThreadCount, queue.GetNumberOfCompletedTasks()); in TEST_F()
462 queue.ResetHistory(); in TEST_F()
463 queue.SetTaskCount(kThreadCount * 4); in TEST_F()
464 queue.SetWorkTime(kFortyFiveMs); in TEST_F()
465 queue.SetAllowHelp(true); // Might outperform Broadcast(). in TEST_F()
467 queue.work_is_available()->Signal(); // Start up one thread. in TEST_F()
471 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
472 while (queue.task_count() != 0) in TEST_F()
473 queue.no_more_tasks()->Wait(); in TEST_F()
477 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
482 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
483 EXPECT_EQ(kThreadCount, queue.GetNumThreadsTakingAssignments()); in TEST_F()
484 EXPECT_EQ(kThreadCount, queue.GetNumThreadsCompletingTasks()); in TEST_F()
485 EXPECT_EQ(0, queue.task_count()); in TEST_F()
486 EXPECT_LE(4, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
487 EXPECT_EQ(4 * kThreadCount, queue.GetNumberOfCompletedTasks()); in TEST_F()
489 queue.SetShutdown(); in TEST_F()
491 queue.work_is_available()->Broadcast(); // Force check for shutdown. in TEST_F()
495 queue.ThreadSafeCheckShutdown(kThreadCount)); in TEST_F()