SpiecsEngine
 
Loading...
Searching...
No Matches

◆ insert_async()

template<uint32_t K>
void scl::kd_tree< K >::insert_async ( const std::vector< item > & points,
Spices::ThreadPool * threadPool )
inline

Insert a point into the kd_tree async. Start at the root, comparing the new point’s first dimension with the root’s first dimension. If the new point’s value is less than the root’s, go to the left child; otherwise, go to the right child. At the next level, compare the second dimension. Continue this process, cycling through dimensions. When a leaf is reached, create a new node and insert the new point.

Parameters
[in]pointsInserted points in k d.
[in]threadPoolThreadPool.
Todo
Only block this task.

Definition at line 608 of file KDTree.h.

609 {
610 std::future<bool> rval = threadPool->SubmitPoolTask([&]() {
611 insert_recursive_async(m_Root, std::make_shared<std::vector<item>>(points), threadPool, 0);
612 return true;
613 });
614 rval.get();
615
619 threadPool->Wait();
620 }
auto SubmitPoolTask(Func &&func, Args &&... args) -> std::future< decltype(func(std::forward< Args >(args)...))>
Submit a task to task queue, and wait for a idle thread to execute it.
void Wait()
Wait for all tasks executed finish in taskqueue.
void insert_recursive_async(Node *&node, std::shared_ptr< std::vector< item > > points, Spices::ThreadPool *threadPool, int depth)
Recursive function to insert a point into the kd_tree async.
Definition KDTree.h:320
Node * m_Root
Pointer to the root node of the tree.
Definition KDTree.h:76