Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions extension/threadpool/threadpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ bool ThreadPool::_unsafe_reset_threadpool(uint32_t new_thread_count) {
return true;
}

void ThreadPool::_unsafe_destroy_threadpool() {
std::lock_guard<std::mutex> lock{mutex_};
ET_LOG(Info, "Destroying threadpool.");
threadpool_.reset();
}

void ThreadPool::run(
runtime::FunctionRef<void(size_t)> fn,
const size_t range) {
Expand Down
9 changes: 9 additions & 0 deletions extension/threadpool/threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ class ThreadPool final {
"This API is experimental and may change without notice. Consider using UseNThreadsThreadPoolGuard")]]
bool _unsafe_reset_threadpool(uint32_t num_threads);

/**
* INTERNAL: Destroys the threadpool. This is not a thread safe call. When calling this method,
* threads of the threadpool might be doing some work. Some other code may
* also be holding on to the threadpool pointer, that is no longer valid.
*/
[[deprecated(
"This API is experimental and may change without notice.")]]
void _unsafe_destroy_threadpool();

/**
* Run, in parallel, function fn(task_id) over task_id in range [0, range).
* This function is blocking. All input is processed by the time it returns.
Expand Down
Loading