- Timestamp:
- Oct 16, 2020 11:16:42 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstIprtList.cpp
r86618 r86619 526 526 } 527 527 528 /** Returns an index that is safe from the removal thread. */ 529 static uint32_t MtTestSafeRandomIndex(MTTEST_LIST_TYPE<MTTEST_TYPE> *pTestList) 530 { 531 uint32_t cItems = (uint32_t)pTestList->size(); 532 if (cItems > MTTEST_ITEMS) 533 cItems -= MTTEST_ITEMS; 534 if (cItems < MTTEST_ITEMS_NOT_REMOVED) 535 cItems = MTTEST_ITEMS_NOT_REMOVED; 536 return RTRandU32Ex(0, cItems - 1); 537 } 538 528 539 /** 529 540 * Thread for inserting items to a shared list. … … 539 550 /* Insert new items in the middle of the list. */ 540 551 for (size_t i = 0; i < MTTEST_ITEMS; ++i) 541 pTestList->insert( pTestList->size() / 2, 0xF0F0F0F0);552 pTestList->insert(MtTestSafeRandomIndex(pTestList), 0xF0F0F0F0); 542 553 543 554 return VINF_SUCCESS; … … 562 573 while (pTestList->isEmpty()) 563 574 RTThreadYield(); 564 uint32_t const idx = RTRandU32Ex(0, RT_MIN((uint32_t)pTestList->size() / 2, MTTEST_ITEMS_NOT_REMOVED)); 565 a = pTestList->at(idx); 575 a = pTestList->at(MtTestSafeRandomIndex(pTestList)); 566 576 } 567 577 … … 586 596 while (pTestList->isEmpty()) 587 597 RTThreadYield(); 588 uint32_t const idx = RTRandU32Ex(0, RT_MIN((uint32_t)pTestList->size() / 2, MTTEST_ITEMS_NOT_REMOVED)); 589 pTestList->replace(idx, 0xFF00FF00); 598 pTestList->replace(MtTestSafeRandomIndex(pTestList), 0xFF00FF00); 590 599 } 591 600
Note:
See TracChangeset
for help on using the changeset viewer.