set_sort_function


Description:

[ Version ( since = "2.10" ) ]
public void set_sort_function (CompareDataFunc<T> func)

Sets the function used to sort the list of tasks.

This allows the tasks to be processed by a priority determined by func, and not just in the order in which they were added to the pool.

Note, if the maximum number of threads is more than 1, the order that threads are executed cannot be guaranteed 100%. Threads are scheduled by the operating system and are executed at random. It cannot be assumed that threads are executed in the order they are created.

Parameters:

this

a ThreadPool

func

the CompareDataFunc used to sort the list of tasks. This function is passed two tasks. It should return 0 if the order in which they are handled does not matter, a negative value if the first task should be processed before the second or a positive value if the second task should be processed first.

user_data

user data passed to func