Debian Codegraph @

src/common/thread.h

raw symbols SCIP
1 /*
2 * Component of the D-ITG 2.8.1 (r1023) platform (http://traffic.comics.unina.it/software/ITG)
3 *
4 * Copyright : (C) 2004-2013 by Alessio Botta, Walter de Donato, Alberto Dainotti,
5 * Stefano Avallone, Antonio Pescape' (PI)
6 * COMICS (COMputer for Interaction and CommunicationS) Group
7 * Department of Electrical Engineering and Information Technologies
8 * University of Napoli "Federico II".
9 * email : [email protected], [email protected], [email protected],
10 * [email protected], [email protected]
11 *
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 * For commercial use please refer to D-ITG Professional.
26 */
27
28
29
30
31 #ifdef WIN32
32 # include <winsock2.h>
33 # include <ws2tcpip.h>
34 # include <iostream>
35
36 typedef HANDLE pthread_t;
37 extern char nameProgram[];
38
39 #endif
40
41 #ifdef UNIX
42 # include <pthread.h>
43 # include <iostream>
44 # include <unistd.h>
45 #endif
46
47
48
49 #ifdef WIN32
50
51 # define MUTEX_THREAD_LOCK(a) \
52 mutexThreadLock(a)
53
54
55 # define MUTEX_THREAD_UNLOCK(a) \
56 mutexThreadUnlock(a)
57
58
59 # define MUTEX_THREAD_RELEASE(a) \
60 mutexThreadRelease(a)
61
62
63 # define CREATE_THREAD(a,b,c,d,e) \
64 createThread(a,b,c,d,e)
65
66
67 # define MUTEX_THREAD_INIT(a) \
68 mutexThreadInit(a)
69
70
71 # define pthread_cleanup_push(a,b)
72 # define pthread_cleanup_pop(a)
73 #endif
74
75 #ifdef UNIX
76
77 # define MUTEX_THREAD_LOCK(a) \
78 mutexThreadLock(&a)
79
80
81 # define MUTEX_THREAD_UNLOCK(a) \
82 mutexThreadUnlock(&a)
83
84
85 # define MUTEX_THREAD_RELEASE(a) \
86 mutexThreadRelease(&a)
87
88
89 # define CREATE_THREAD(a,b,c,d,e) \
90 createThread(a,b,c,d,e)
91
92
93 # define MUTEX_THREAD_INIT(a) \
94 mutexThreadInit(&a)
95 #endif
96
97
98
99
100
101 int createThread(void *argument, void *(nameFunction) (void *), void *attrib, pthread_t& idThread, bool detach);
102
103
104 int joinThread(int numFlow, pthread_t hThr[]);
105
106
107 int terminateThread(pthread_t idThread);
108
109
110 void exitThread();
111
112
113
114 #ifdef WIN32
115
116 int mutexThreadInit(HANDLE &mutex);
117 #endif
118
119 #ifdef UNIX
120
121 int mutexThreadInit(void* mutex);
122 #endif
123
124
125 int mutexThreadRelease(void* mutex);
126
127
128 int mutexThreadLock(void* mutex);
129
130
131 int mutexThreadUnlock(void* mutex);
132
133
134
135
136 int closeSock(int socket);