hcyrano wrote:i see other little thing,
many methods are not synchronised, idle_thread_exists(), thread_is_available(), so many threads can have same information.
but only one (split() is synchronised) can take the slave thread.
this code seems good but this is not a waste of time?  == delete many call at these methods?
I haven't tested, but actually I think it saves time.  I call idle_thread_exists() without locking from search_pv() and search(), when deciding whether to split.  Because all threads are usually busy, idle_thread_exists() will almost always return false.  Avoiding locking here saves time, and is (as far as I can see) entirely safe.  
In the split() function, I call idle_thread_exists() again, to make sure some other thread hasn't stolen the idle threads in the meantime.  At this time I do use locking, which is necessary to avoid race conditions.  
Said in another way:  It is true that I waste some time when two threads try to grab the same slave thread simultaneously, but I think this is more than compensated by not having to lock and unlock so often.  Locks are very expensive.
ps: really a great job, congrats, i think use your code in my program
Thanks!  I hope you find a way to use it.  
 
Tord