Lines Matching full:queue
257 WorkQueue queue(kThreadCount); // Start the threads. in TEST_F() local
264 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
265 while (!queue.EveryIdWasAllocated()) in TEST_F()
266 queue.all_threads_have_ids()->Wait(); in TEST_F()
271 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
275 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
276 EXPECT_EQ(0, queue.GetNumThreadsTakingAssignments()); in TEST_F()
277 EXPECT_EQ(0, queue.GetNumThreadsCompletingTasks()); in TEST_F()
278 EXPECT_EQ(0, queue.task_count()); in TEST_F()
279 EXPECT_EQ(0, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
280 EXPECT_EQ(0, queue.GetMinCompletionsByWorkerThread()); in TEST_F()
281 EXPECT_EQ(0, queue.GetNumberOfCompletedTasks()); in TEST_F()
285 queue.ResetHistory(); in TEST_F()
286 queue.SetTaskCount(kTaskCount); in TEST_F()
287 queue.SetWorkTime(kThirtyMs); in TEST_F()
288 queue.SetAllowHelp(true); in TEST_F()
293 queue.work_is_available()->Signal(); // But each worker can signal another. in TEST_F()
295 queue.SpinUntilTaskCountLessThan(kTaskCount); in TEST_F()
297 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
301 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
302 while (queue.task_count()) in TEST_F()
303 queue.no_more_tasks()->Wait(); in TEST_F()
308 EXPECT_LE(2, queue.GetNumThreadsTakingAssignments()); in TEST_F()
309 EXPECT_EQ(kTaskCount, queue.GetNumberOfCompletedTasks()); in TEST_F()
312 queue.ResetHistory(); in TEST_F()
313 queue.SetTaskCount(3); in TEST_F()
314 queue.SetWorkTime(kThirtyMs); in TEST_F()
315 queue.SetAllowHelp(false); in TEST_F()
317 queue.work_is_available()->Broadcast(); // Make them all try. in TEST_F()
319 queue.SpinUntilTaskCountLessThan(3); in TEST_F()
321 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
324 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
325 EXPECT_EQ(3, queue.GetNumThreadsTakingAssignments()); in TEST_F()
326 EXPECT_EQ(3, queue.GetNumThreadsCompletingTasks()); in TEST_F()
327 EXPECT_EQ(0, queue.task_count()); in TEST_F()
328 EXPECT_EQ(1, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
329 EXPECT_EQ(0, queue.GetMinCompletionsByWorkerThread()); in TEST_F()
330 EXPECT_EQ(3, queue.GetNumberOfCompletedTasks()); in TEST_F()
333 queue.ResetHistory(); in TEST_F()
334 queue.SetTaskCount(3); in TEST_F()
335 queue.SetWorkTime(kThirtyMs); in TEST_F()
336 queue.SetAllowHelp(true); // Allow (unnecessary) help requests. in TEST_F()
338 queue.work_is_available()->Broadcast(); // Signal all threads. in TEST_F()
340 queue.SpinUntilTaskCountLessThan(3); in TEST_F()
342 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
345 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
346 EXPECT_EQ(3, queue.GetNumThreadsTakingAssignments()); in TEST_F()
347 EXPECT_EQ(3, queue.GetNumThreadsCompletingTasks()); in TEST_F()
348 EXPECT_EQ(0, queue.task_count()); in TEST_F()
349 EXPECT_EQ(1, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
350 EXPECT_EQ(0, queue.GetMinCompletionsByWorkerThread()); in TEST_F()
351 EXPECT_EQ(3, queue.GetNumberOfCompletedTasks()); in TEST_F()
354 queue.ResetHistory(); in TEST_F()
355 queue.SetTaskCount(20); // 2 tasks per thread. in TEST_F()
356 queue.SetWorkTime(kThirtyMs); in TEST_F()
357 queue.SetAllowHelp(true); in TEST_F()
359 queue.work_is_available()->Signal(); // But each worker can signal another. in TEST_F()
361 queue.SpinUntilTaskCountLessThan(20); in TEST_F()
363 queue.SpinUntilAllThreadsAreWaiting(); // Should take about 60 ms. in TEST_F()
366 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
367 EXPECT_EQ(10, queue.GetNumThreadsTakingAssignments()); in TEST_F()
368 EXPECT_EQ(10, queue.GetNumThreadsCompletingTasks()); in TEST_F()
369 EXPECT_EQ(0, queue.task_count()); in TEST_F()
370 EXPECT_EQ(20, queue.GetNumberOfCompletedTasks()); in TEST_F()
373 queue.ResetHistory(); in TEST_F()
374 queue.SetTaskCount(20); // 2 tasks per thread. in TEST_F()
375 queue.SetWorkTime(kThirtyMs); in TEST_F()
376 queue.SetAllowHelp(true); in TEST_F()
378 queue.work_is_available()->Broadcast(); in TEST_F()
380 queue.SpinUntilTaskCountLessThan(20); in TEST_F()
382 queue.SpinUntilAllThreadsAreWaiting(); // Should take about 60 ms. in TEST_F()
385 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
386 EXPECT_EQ(10, queue.GetNumThreadsTakingAssignments()); in TEST_F()
387 EXPECT_EQ(10, queue.GetNumThreadsCompletingTasks()); in TEST_F()
388 EXPECT_EQ(0, queue.task_count()); in TEST_F()
389 EXPECT_EQ(20, queue.GetNumberOfCompletedTasks()); in TEST_F()
391 queue.SetShutdown(); in TEST_F()
393 queue.work_is_available()->Broadcast(); // Force check for shutdown. in TEST_F()
396 queue.ThreadSafeCheckShutdown(kThreadCount)); in TEST_F()
401 WorkQueue queue(kThreadCount); // Start the threads. in TEST_F() local
408 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
409 while (!queue.EveryIdWasAllocated()) in TEST_F()
410 queue.all_threads_have_ids()->Wait(); in TEST_F()
414 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
418 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
419 EXPECT_EQ(0, queue.GetNumThreadsTakingAssignments()); in TEST_F()
420 EXPECT_EQ(0, queue.GetNumThreadsCompletingTasks()); in TEST_F()
421 EXPECT_EQ(0, queue.task_count()); in TEST_F()
422 EXPECT_EQ(0, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
423 EXPECT_EQ(0, queue.GetMinCompletionsByWorkerThread()); in TEST_F()
424 EXPECT_EQ(0, queue.GetNumberOfCompletedTasks()); in TEST_F()
427 queue.ResetHistory(); in TEST_F()
428 queue.SetTaskCount(20 * kThreadCount); in TEST_F()
429 queue.SetWorkTime(kFortyFiveMs); in TEST_F()
430 queue.SetAllowHelp(false); in TEST_F()
432 queue.work_is_available()->Broadcast(); // Start up all threads. in TEST_F()
435 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
436 while (queue.task_count() != 0) in TEST_F()
437 queue.no_more_tasks()->Wait(); in TEST_F()
441 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
446 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
447 EXPECT_EQ(kThreadCount, queue.GetNumThreadsTakingAssignments()); in TEST_F()
448 EXPECT_EQ(kThreadCount, queue.GetNumThreadsCompletingTasks()); in TEST_F()
449 EXPECT_EQ(0, queue.task_count()); in TEST_F()
450 EXPECT_LE(20, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
451 EXPECT_EQ(20 * kThreadCount, queue.GetNumberOfCompletedTasks()); in TEST_F()
454 queue.ResetHistory(); in TEST_F()
455 queue.SetTaskCount(kThreadCount * 4); in TEST_F()
456 queue.SetWorkTime(kFortyFiveMs); in TEST_F()
457 queue.SetAllowHelp(true); // Might outperform Broadcast(). in TEST_F()
459 queue.work_is_available()->Signal(); // Start up one thread. in TEST_F()
463 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
464 while (queue.task_count() != 0) in TEST_F()
465 queue.no_more_tasks()->Wait(); in TEST_F()
469 queue.SpinUntilAllThreadsAreWaiting(); in TEST_F()
474 base::AutoLock auto_lock(*queue.lock()); in TEST_F()
475 EXPECT_EQ(kThreadCount, queue.GetNumThreadsTakingAssignments()); in TEST_F()
476 EXPECT_EQ(kThreadCount, queue.GetNumThreadsCompletingTasks()); in TEST_F()
477 EXPECT_EQ(0, queue.task_count()); in TEST_F()
478 EXPECT_LE(4, queue.GetMaxCompletionsByWorkerThread()); in TEST_F()
479 EXPECT_EQ(4 * kThreadCount, queue.GetNumberOfCompletedTasks()); in TEST_F()
481 queue.SetShutdown(); in TEST_F()
483 queue.work_is_available()->Broadcast(); // Force check for shutdown. in TEST_F()
487 queue.ThreadSafeCheckShutdown(kThreadCount)); in TEST_F()
739 // Get our task duration from the queue. in ThreadMain()