-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a simple thread pool #1746
Add a simple thread pool #1746
Conversation
interesting alternative solution, although the ReadSampleAsync "functionality" should be completely rewritten in a future can in the meantime be an improvement |
#include <vector> | ||
|
||
#pragma once | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add appropriate namespaces such as the others utils files
at least the "utils"
namespace UTILS
{
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested on windows and android
not found problems
Description
Implement a simple thread pool so threads can be reused instead of recreated.
Motivation and context
inputstream.adaptive creates a lot of threads though
std::async
or by instantiatingstd::thread
directly. E.g. watching this stream I measured about 90 threads being created and destroyed per second (very inaccurate measure using a stopwatch and GDB debug output):Creating threads is a non trivial task and reusing threads instead of recreating them improves efficiency.
How has this been tested?
Tested with the above stream and https://github.com/anxdpanic/plugin.video.youtube/. I confirmed in GDB on Linux that the thread pool grows to a size of only two and then no new threads are created.
Types of change
Checklist: