[MS] If I mark my thread pool callback as long-running, does it still count toward the thread pool thread limit? - devamazonaws.blogspot.com

The Windows thread pool lets you declare that your callback is long-running. Depending on which interface you are using, this could be by calling Set­Threadpool­Callback­Runs­Long, or by calling Callback­May­Run­Long, or by passing the WT_EXECUTE­LONG­FUNCTION flag to Queue­User­Work­Item.

If you mark a callback as long-running, does it still count against the thread pool thread limit?

Yes. A long-running thread pool callback still runs in the thread pool and still counts as a thread pool thread.

Marking a flag as long-running is a hint to the thread pool manager that if it has other callbacks that are due, and it's hoping that this callback will be finished soon so that it can use the thread to run those other callbacks, well, maybe it shouldn't wait and should just go ahead and create another thread (assuming that the thread limit has not been reached).

We saw a demonstration of this some time ago where we showed that marking a callback as long-running informed the thread pool that it should create a new thread rather than wait for the existing callback to finish.

But it's still in the thread pool, and it counts as a thread pool thread. It's not a "get out of thread pool free" card.


Post Updated on May 14, 2025 at 03:00PM
Thanks for reading
from devamazonaws.blogspot.com

Comments

Popular posts from this blog

Scenarios capability now generally available for Amazon Q in QuickSight - devamazonaws.blogspot.com

Research and Engineering Studio on AWS Version 2024.08 now available - devamazonaws.blogspot.com

Amazon EC2 C6id instances are now available in AWS Europe (Paris) region - devamazonaws.blogspot.com