OSDN Git Service

30f965487737aeaccb88d75f7d92e95cf4312a36
[ntch/develop.git] / src / inc / utils / nt_pthread.h
1 /* Copyright 2013 Akira Ohta (akohta001@gmail.com)
2     This file is part of ntch.
3
4     The ntch is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
8
9     The ntch is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with ntch.  If not, see <http://www.gnu.org/licenses/>.
16     
17 */
18 #ifndef _NT_PTHREAD_h_
19 #define _NT_PTHREAD_h_
20 #include <pthread.h>
21 #include <semaphore.h>
22
23
24 #define NT_PTHREAD_RESULT_NONE 0
25 #define NT_PTHREAD_RESULT_UPDATE_BOARD 1
26
27 typedef struct tag_nt_pthread_handle *nt_pthread_handle;
28 typedef struct tag_nt_pthread_handle{
29         int chk_sum;
30 }nt_pthread_handle_t;
31
32 //typedef struct tag_nt_pthread_result_t *nt_pthread_result_tp;
33 typedef struct tag_nt_pthread_result_t{
34         int code;
35         void *data;
36 }nt_pthread_result_t;
37
38 typedef nt_pthread_result_t (*nt_pthread_fn)(void* data);
39 typedef nt_pthread_result_t (*nt_pthread_result_fn)(nt_pthread_result_t result);
40
41 extern BOOL nt_pthread_lib_init(int thread_pool_size, int queue_size,
42                 const char **error_msg);
43 extern void nt_pthread_lib_finish();
44
45 extern BOOL nt_pthread_put_que(nt_pthread_handle h_pthread);
46 extern nt_pthread_result_t nt_pthread_get_result_from_que();
47
48
49 extern nt_pthread_handle nt_pthread_alloc(
50                         nt_pthread_fn func, void *param, 
51                         nt_pthread_result_fn result_func);
52
53 extern int nt_pthread_add_ref(nt_pthread_handle h_pthread);
54 extern int nt_pthread_release_ref(nt_pthread_handle h_pthread);
55
56
57
58 #endif /* _NT_PTHREAD_h_ */