Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc
| Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
| TEST(LockfreeLinkList, InsertMultipleConcurrent) | TEST(LockfreeLinkList, InsertMultipleConcurrent) | ||||
| { | { | ||||
| static const int num_nodes = 655360; | static const int num_nodes = 655360; | ||||
| /* Initialize list. */ | /* Initialize list. */ | ||||
| LockfreeLinkList list; | LockfreeLinkList list; | ||||
| BLI_linklist_lockfree_init(&list); | BLI_linklist_lockfree_init(&list); | ||||
| /* Initialize task scheduler and pool. */ | /* Initialize task scheduler and pool. */ | ||||
| TaskPool *pool = BLI_task_pool_create_suspended(&list, TASK_PRIORITY_HIGH); | TaskPool *pool = BLI_task_pool_create_suspended(&list, TASK_PRIORITY_HIGH, TASK_ISOLATION_ON); | ||||
| /* Push tasks to the pool. */ | /* Push tasks to the pool. */ | ||||
| for (int i = 0; i < num_nodes; ++i) { | for (int i = 0; i < num_nodes; ++i) { | ||||
| BLI_task_pool_push(pool, concurrent_insert, POINTER_FROM_INT(i), false, nullptr); | BLI_task_pool_push(pool, concurrent_insert, POINTER_FROM_INT(i), false, nullptr); | ||||
| } | } | ||||
| /* Run all the tasks. */ | /* Run all the tasks. */ | ||||
| BLI_task_pool_work_and_wait(pool); | BLI_task_pool_work_and_wait(pool); | ||||
| /* Verify we've got all the data properly inserted. */ | /* Verify we've got all the data properly inserted. */ | ||||
| EXPECT_EQ(list.head, &list.dummy_node); | EXPECT_EQ(list.head, &list.dummy_node); | ||||
| Show All 19 Lines | |||||