Go to the source code of this file.
Functions | |
| void | sanei_thread_init (void) |
| Initialize sanei_thread. | |
| SANE_Bool | sanei_thread_is_forked (void) |
| Do we use processes or threads? | |
| SANE_Pid | sanei_thread_begin (int(*func)(void *args), void *args) |
| Spawn a new task. | |
| int | sanei_thread_kill (SANE_Pid pid) |
| Terminate spawned task. | |
| int | sanei_thread_sendsig (SANE_Pid pid, int sig) |
| Send a signal to a task. | |
| SANE_Pid | sanei_thread_waitpid (SANE_Pid pid, int *status) |
| Wait for task termination. | |
| SANE_Status | sanei_thread_get_status (SANE_Pid pid) |
| Check the current status of the spawned task. | |
Backends should not use fork() directly because fork() does not work correctly on some platforms. Use the functions provided by sanei_thread instead. The build system decides if fork() or threads are used.
Please keep in mind that the behaviour of the child process depends on if it's a process or thread especially concerning variables.
In this file we use "task" as an umbrella term for process and thread.
| void sanei_thread_init | ( | void | ) |
Initialize sanei_thread.
This function must be called before any other sanei_thread function.
| SANE_Bool sanei_thread_is_forked | ( | void | ) |
Do we use processes or threads?
This function can be used to check if processes or threads are used.
| SANE_Pid sanei_thread_begin | ( | int(*)(void *args) | func, | |
| void * | args | |||
| ) |
Spawn a new task.
This function should be used to start a new task.
| func() | function to call as child task | |
| args | argument of the function (only one!) |
| int sanei_thread_kill | ( | SANE_Pid | pid | ) |
Terminate spawned task.
This function terminates the task that was created with sanei_thread_begin.
For processes, SIGTERM is sent. If threads are used, pthread_cancel() terminates the task.
| pid | - the id of the task |
| int sanei_thread_sendsig | ( | SANE_Pid | pid, | |
| int | sig | |||
| ) |
Send a signal to a task.
This function can be used to send a signal to a task.
For terminating the task, sanei_thread_kill() should be used.
| pid | - the id of the task | |
| sig | - the signal to send |
| SANE_Pid sanei_thread_waitpid | ( | SANE_Pid | pid, | |
| int * | status | |||
| ) |
Wait for task termination.
This function waits until a task that has been terminated by sanei_thread_kill(), sanei_thread_sendsys() or by any other means is finished.
| pid | - the id of the task | |
| status | - status of the task that has just finished |
| SANE_Status sanei_thread_get_status | ( | SANE_Pid | pid | ) |
Check the current status of the spawned task.
| pid | - the id of the task |
1.5.1