![]() |
libcrystfel 0.11.1-244-g4019144e+
|
Typedefs | |
| typedef void *(* | TPGetTaskFunc) (void *qargs) |
| typedef void(* | TPWorkFunc) (void *work, int cookie) |
| typedef void(* | TPFinalFunc) (void *qargs, void *work) |
Functions | |
| signed int | get_status_label (void) |
| int | run_threads (int n_threads, TPWorkFunc work, TPGetTaskFunc get_task, TPFinalFunc final, void *queue_args, int max, int cpu_num, int cpu_groupsize, int cpu_offset) |
Thread pool.
| typedef void(* TPFinalFunc) (void *qargs, void *work) |
| qargs | The queue_args pointer which was given to run_threads. |
| work | The pointer which was returned by your get_task function. |
This function is called, non-reentrantly, after each work item has been completed. A typical use might be to update some counters inside qargs according to fields withing work which were filled by your 'work' function.
| typedef void *(* TPGetTaskFunc) (void *qargs) |
qargs: The queue_args pointer which was given to run_threads().
This function is called, non-reentrantly, to get a new work item to give to your work function. The stuff you need to generate the new work item should have been stored in qargs which was passed to run_threads.
| typedef void(* TPWorkFunc) (void *work, int cookie) |
| work | The queue_args pointer which was given to run_threads. |
| cookie | A small integral number which is guaranteed to be unique among all currently running threads. |
This function is called, reentrantly, for each work item.
|
extern |
| n_threads | The number of threads to run in parallel |
| work | The function to be called to do the work |
| get_task | The function which will determine the next unassigned task |
| final | The function which will be called to clean up after a task |
| queue_args | A pointer to any data required to determine the next task |
| max | Stop calling get_task after starting this number of jobs |
| cpu_num | Ignored |
| cpu_groupsize | Ignored |
| cpu_offset | Ignored |
get_task will be called every time a worker is idle. It returns either NULL, indicating that no further work is available, or a pointer which will be passed to work.
final will be called once per image, and will be given both queue_args and the last task pointer.
get_task and final will be called only under lock, and so do NOT need to be re-entrant or otherwise thread safe. 'work', of course, needs to be thread safe.
Work will stop after max tasks have been processed whether get_task returned NULL or not. If max is zero, all tasks will be processed.