2014-07-01 12:33 GMT+02:00 Saúl Ibarra Corretgé <[email protected]>: >> Multiple approachs: >> >> 1) uv_set_threadpool_size(int) can be called just once (per >> loop?). >> > > You can use the env variable now, we either do it right all the way or > we don't.
"env variable"? what? which environment variable? Please, don't tell me that I can set the threadpool size by setting an "environment variable" before running my UV-based program... please not. > Also note that the threadpool is global, not per loop. > >> 2) Keep state: >> >> - int uv__num_threads_in_use: number of active thread being used. - >> int uv__threadpool_size: max number of threads (seteable, and at >> some point can be least than uv__num_threads_in_use). >> >> - When calling uv_queue_work(), just add a new thread if >> uv__threadpool_size > uv__num_threads_in_use. Otherwise enqueue >> it. >> >> - When a work ends check if (uv__threadpool_size < >> uv__num_threads_in_use). If so kill/delete the thread associated to >> that work. >> >> Does it make sense? >> > > Sure. Shrinking the pool would only work after the work is completed, > which I guess is ok. A lot of care must be taken with locking since > this function needs to take the global mutex. Thread count should > never go below 4. > Also, when threadpool size changes, what do we do > with the memory allocated for those threads? I don't know how such a memory is allocated, but I guess "it should be reallocated" XD > Feel free to submit a PR and I'll take a look! Honestly I've never played with uv_queue_work() so it would be hard for me to properly do something. It was just a suggestion. If at some time I needed uv_queue_work() then I would involve myself on it. Regards. -- Iñaki Baz Castillo <[email protected]> -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
