2014-07-01 11:44 GMT+02:00 Saúl Ibarra Corretgé <[email protected]>:
> What if threads are blocked doing something and you shrink the
> threadpool? How do we "kill" those threads? If you are thinking about
> using signals, what if they are doing CPU-intensive work?

Multiple approachs:

1) uv_set_threadpool_size(int) can be called just once (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?



-- 
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.

Reply via email to