SANEI  1.2.1.194-728ca
sanei_thread.h
Go to the documentation of this file.
1 /* sane - Scanner Access Now Easy.
2  Copyright (C) 1998-2001 Yuri Dario
3  Copyright (C) 2002-2003 Henning Meier-Geinitz (documentation)
4  Copyright (C) 2003-2004 Gerhard Jaeger (pthread/process support)
5  This file is part of the SANE package.
6 
7  SANE is free software; you can redistribute it and/or modify it under
8  the terms of the GNU General Public License as published by the Free
9  Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  SANE is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15  for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with sane; see the file COPYING.
19  If not, see <https://www.gnu.org/licenses/>.
20 
21  As a special exception, the authors of SANE give permission for
22  additional uses of the libraries contained in this release of SANE.
23 
24  The exception is that, if you link a SANE library with other files
25  to produce an executable, this does not by itself cause the
26  resulting executable to be covered by the GNU General Public
27  License. Your use of that executable is in no way restricted on
28  account of linking the SANE library code into it.
29 
30  This exception does not, however, invalidate any other reasons why
31  the executable file might be covered by the GNU General Public
32  License.
33 
34  If you submit changes to SANE to the maintainers to be included in
35  a subsequent release, you agree by submitting the changes that
36  those changes may be distributed with this exception intact.
37 
38  If you write modifications of your own for SANE, it is your choice
39  whether to permit this exception to apply to your modifications.
40  If you do not wish that, delete this exception notice.
41 
42 */
43 
59 #ifndef sanei_thread_h
60 #define sanei_thread_h
61 #include "../include/sane/config.h"
62 
63 #ifdef USE_PTHREAD
64 #include <pthread.h>
65 typedef pthread_t SANE_Pid;
66 #else
67 typedef int SANE_Pid;
68 #endif
69 
74 extern void sanei_thread_init (void);
75 
84 extern SANE_Bool sanei_thread_is_forked (void);
85 
95 extern SANE_Bool sanei_thread_is_valid (SANE_Pid pid);
96 
115 #define sanei_thread_invalidate(pid) ((pid) = (SANE_Pid)(-1))
116 
127 #define sanei_thread_initialize sanei_thread_invalidate
128 
140 extern SANE_Pid sanei_thread_begin (int (*func) (void *args), void *args);
141 
155 extern int sanei_thread_kill (SANE_Pid pid);
156 
170 extern int sanei_thread_sendsig (SANE_Pid pid, int sig);
171 
184 extern SANE_Pid sanei_thread_waitpid (SANE_Pid pid, int *status);
185 
195 extern SANE_Status sanei_thread_get_status (SANE_Pid pid);
196 
197 #endif /* sanei_thread_h */
SANE_Status sanei_thread_get_status(SANE_Pid pid)
Check the current status of the spawned task.
void sanei_thread_init(void)
Initialize sanei_thread.
SANE_Bool sanei_thread_is_valid(SANE_Pid pid)
Is SANE_Pid valid pid?
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.
SANE_Pid sanei_thread_waitpid(SANE_Pid pid, int *status)
Wait for task termination.
int sanei_thread_sendsig(SANE_Pid pid, int sig)
Send a signal to a task.
SANE_Bool sanei_thread_is_forked(void)
Do we use processes or threads?