progschj / ThreadPool

A simple C++11 Thread Pool implementation
zlib License
7.85k stars 2.24k forks source link

Add a variable to control the tasks size #46

Open MatthewButterfly opened 7 years ago

MatthewButterfly commented 7 years ago

A program may accepts many tasks at the same time, it will grow the memory to use. If the memory is taken a lot by the program, the system will kill the program. May the library add a variable to control the max tasks can be added to the std::queue? Thanks.

  1. // the task queue
  2. std::queue< std::function<void()> > tasks;
jhasse commented 6 years ago

What should happen when the maximum is reached? Throw an exception or block until a task has finished?