Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
quote the arguments to --log since they are not quoted enough in tesh files to suppor...
[simgrid.git] / win32_test_app / include / TThreadDynarray.h
1 #ifndef __THREAD_DYNARRAY_H__
2 #define __THREAD_DYNARRAY_H__
3
4 #include <stddef.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <windows.h>
8 #include <TTestCaseContext.h>
9
10
11 typedef struct s_ThreadEntry {
12   HANDLE hThread;
13   DWORD threadId;
14   TestCaseContext_t context;
15 } s_ThreadEntry_t, *ThreadEntry_t;
16 /*
17  * s_ThreadDynarray struct declaration.
18  */
19
20 typedef struct s_ThreadDynarray {
21   /* threads */
22   ThreadEntry_t threads;
23   /* thread count */
24   unsigned long count;
25   /* Storage capacity */
26   unsigned long capacity;
27   CRITICAL_SECTION cs;
28   bool is_locked;
29
30 } s_ThreadDynarray_t, *ThreadDynarray_t;
31
32 /*
33  * Constructs a ThreadDynarray with the specified capacity.
34  */
35 ThreadDynarray_t ThreadDynarray_new(unsigned long capacity);
36
37 /* 
38  * Destroy the ThreadDynarray 
39  */
40 void ThreadDynarray_destroy(ThreadDynarray_t ptr);
41
42 /*
43  * Returns an const pointer THREAD_entry pointed to by index.
44  */
45 ThreadEntry_t const ThreadDynarray_at(ThreadDynarray_t ptr,
46                                       unsigned long index);
47
48 /*
49  * Fill the content of the entry addressed by the __entry with the content
50  * of the entry pointed to by index.
51  */
52 void ThreadDynarray_get(ThreadDynarray_t ptr, unsigned long index,
53                         ThreadEntry_t const __entry);
54
55 /* 
56  * Fill the content of the entry pointed to by index with the content of
57  * the entry addressed by __entry.
58  */
59 void ThreadDynarray_set(ThreadDynarray_t ptr, unsigned long index,
60                         ThreadEntry_t const __entry);
61
62 /*
63  * Returns a const pointer to the first entry.
64  */
65 ThreadEntry_t const ThreadDynarray_getFront(ThreadDynarray_t ptr);
66
67 /*
68  * Returns a const pointer to the last entry.
69  */
70 ThreadEntry_t const ThreadDynarray_getBack(ThreadDynarray_t ptr);
71
72 /*
73  * Inserts a copy of __entry at the front
74  */
75 void ThreadDynarray_pushFront(ThreadDynarray_t ptr,
76                               ThreadEntry_t const __entry);
77
78 /*
79  * Appends a copy of __entry to the end.
80  */
81 void ThreadDynarray_pushBack(ThreadDynarray_t ptr,
82                              ThreadEntry_t const __entry);
83
84 /* 
85  * Inserts __entry at the position pointed to by index.
86  */
87 void ThreadDynarray_insert(ThreadDynarray_t ptr, unsigned long index,
88                            ThreadEntry_t const __entry);
89
90 /*
91  * Deletes the entry pointed to by index. If __entry is not NULL the
92  * fuction saves the entry threads at this address before.
93  */
94 void ThreadDynarray_erase(ThreadDynarray_t ptr, unsigned long index,
95                           ThreadEntry_t const __entry);
96
97 /*
98  * Find the first entry with the same content of the entry addressed by
99  * __entry.The function returns the index of the founded entry, -1 if
100  * no entry is founded.
101  */
102 long ThreadDynarray_getIndex(ThreadDynarray_t ptr,
103                              ThreadEntry_t const __entry);
104
105 /* 
106  * Returns true if the entry exist.
107  */
108 bool ThreadDynarray_exist(ThreadDynarray_t ptr,
109                           ThreadEntry_t const __entry);
110
111 /* Deletes the first entry with the same content of the entry addressed
112  * by __entry.The function returns true if the entry is deleted, false
113  * if no entry is founded.
114  */
115 bool ThreadDynarray_remove(ThreadDynarray_t ptr,
116                            ThreadEntry_t const __entry);
117
118 /*
119  * Erase all elements of the self.
120  */
121 void ThreadDynarray_clear(ThreadDynarray_t ptr);
122
123 /*
124  * Resets entry count to zero.
125  */
126 void ThreadDynarray_reset(ThreadDynarray_t ptr);
127
128 /*
129  * Moves count elements from src index to dst index.
130  */
131 void ThreadDynarray_move(ThreadDynarray_t ptr, const unsigned long dst,
132                          const unsigned long src, unsigned long count);
133
134 /* Compare the content of the entry pointed to by index with the content of
135  * the entry addressed by __entry. The function returns true if the contents
136  * are same.
137  */
138 bool ThreadDynarray_compare(ThreadDynarray_t ptr,
139                             const unsigned long index,
140                             ThreadEntry_t const __entry);
141
142 /*
143  * Returns a reference to a new ThreadDynarray new set is a clone of the self.
144  */
145 ThreadDynarray_t ThreadDynarray_clone(ThreadDynarray_t ptr);
146
147 /*
148  * Extends the capacity when the container is full.
149  */
150 void ThreadDynarray_resize(ThreadDynarray_t ptr);
151
152 /*
153  * Returns the number of elements.
154  */
155 unsigned long ThreadDynarray_getCount(ThreadDynarray_t ptr);
156
157 /*
158  * Returns the current storage capacity of the ThreadDynarray. This is guaranteed
159  * to be at least as large as count().
160  */
161 unsigned long ThreadDynarray_getCapacity(ThreadDynarray_t ptr);
162
163 /*
164  * Returns upper bound of self (max index).
165  */
166 unsigned long ThreadDynarray_getUpperBound(ThreadDynarray_t ptr);
167
168 /*
169  * Returns lower bound of self (always zero).
170  */
171 unsigned long ThreadDynarray_getLowerBound(ThreadDynarray_t ptr);
172
173 /*
174  * Returns the size of the elements.
175  */
176 unsigned long ThreadDynarray_getElementSize(ThreadDynarray_t ptr);
177
178 /*
179  * Returns true if the size of self is zero.
180  */
181 bool ThreadDynarray_isEmpty(ThreadDynarray_t ptr);
182
183 /*
184  * Returns true if capacity available.
185  */
186 bool ThreadDynarray(ThreadDynarray_t ptr);
187
188 /*
189  * Returns true if the container is full.
190  */
191 bool ThreadDynarray_is_full(ThreadDynarray_t ptr);
192
193  /*
194   * Returns true if capacity available.
195   */
196 bool ThreadDynarray_getCapacityAvailable(ThreadDynarray_t ptr);
197
198 /* 
199  * Assignement.
200  */
201 ThreadDynarray_t ThreadDynarray_assign(ThreadDynarray_t src,
202                                        ThreadDynarray_t dst);
203
204 /* 
205  * Returns true if the dynamic arrays are equal.
206  */
207 bool ThreadDynarray_areEquals(ThreadDynarray_t ptr1,
208                               ThreadDynarray_t ptr2);
209
210 /* 
211  * Returns true if the dynamic arrays are not equal.
212  */
213 bool ThreadDynarray_areNotEquals(ThreadDynarray_t ptr1,
214                                  ThreadDynarray_t ptr2);
215
216 void ThreadDynarray_lock(ThreadDynarray_t ptr);
217
218 void ThreadDynarray_unlock(ThreadDynarray_t ptr);
219
220
221 #endif                          /* #ifndef __THREAD_DYNARRAY_H__ */