Changeset View
Changeset View
Standalone View
Standalone View
tests/gtests/blenlib/BLI_linklist_lockfree_test.cc
| Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| static const int num_threads = 512; | static const int num_threads = 512; | ||||
| 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. */ | ||||
| TaskScheduler *scheduler = BLI_task_scheduler_create(num_threads); | TaskScheduler *scheduler = BLI_task_scheduler_create(num_threads); | ||||
| TaskPool *pool = BLI_task_pool_create_suspended(scheduler, &list); | TaskPool *pool = BLI_task_pool_create_suspended(scheduler, &list, TASK_PRIORITY_HIGH); | ||||
| /* 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, TASK_PRIORITY_HIGH); | BLI_task_pool_push(pool, concurrent_insert, POINTER_FROM_INT(i), false, NULL); | ||||
| } | } | ||||
| /* Run all the tasks. */ | /* Run all the tasks. */ | ||||
| BLI_threaded_malloc_begin(); | BLI_threaded_malloc_begin(); | ||||
| BLI_task_pool_work_and_wait(pool); | BLI_task_pool_work_and_wait(pool); | ||||
| BLI_threaded_malloc_end(); | BLI_threaded_malloc_end(); | ||||
| /* 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); | ||||
| bool *visited_nodes = (bool *)MEM_callocN(sizeof(bool) * num_nodes, "visited nodes"); | bool *visited_nodes = (bool *)MEM_callocN(sizeof(bool) * num_nodes, "visited nodes"); | ||||
| Show All 19 Lines | |||||