Skip to content
Closed
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
4 changes: 2 additions & 2 deletions Modules/Core/Common/src/itkPoolMultiThreader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ PoolMultiThreader::SingleMethodExecute()
// so now it waits for each of the other work units to finish
for (threadLoop = 1; threadLoop < m_NumberOfWorkUnits; ++threadLoop)
{
exceptionHandler.TryAndCatch([this, threadLoop] { m_ThreadInfoArray[threadLoop].Future.get(); });
exceptionHandler.TryAndCatch([this, threadLoop] { (void)m_ThreadInfoArray[threadLoop].Future.get(); });
Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker Mar 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does Future.get() return? And why is it OK to ignore its return value?

I'm asking, because maybe we should use the std::future<void> specialization, for Future: https://en.cppreference.com/w/cpp/thread/future/get.html
std::future<void>::get() returns void. It looks like that's what we want, right?

In general, I think it's preferable to avoid unnecessary casting 🤷

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::future<ITK_THREAD_RETURN_TYPE> Future;

ITK_THREAD_RETURN_TYPE depends on the platform.

I don't understand what you are suggesting. Could you please make an alternate proposal?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see:

ITK_THREAD_RETURN_TYPE is a pointer type when using Pthreads:

using ITK_THREAD_RETURN_TYPE = void *;

And it's unsigned int when using WIN32 threads:

using ITK_THREAD_RETURN_TYPE = unsigned int;

But "normally" it's just void:

using ITK_THREAD_RETURN_TYPE = void;

Are Pthreads and WIN32 threads both still actively supported nowadays?

}

exceptionHandler.RethrowFirstCaughtException();
Expand Down Expand Up @@ -300,7 +300,7 @@ PoolMultiThreader::ParallelizeImageRegion(unsigned int dimension,
filter->IncrementProgress(0);
}
} while (status != std::future_status::ready);
m_ThreadInfoArray[i].Future.get();
(void)m_ThreadInfoArray[i].Future.get();
reporter.CompletedPixel();
});
}
Expand Down