This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | GW_PRIOQUEUE_H 1 |
| #define | gw_prioqueue_produce(queue, item) gw_prioqueue_insert(queue, item) |
Typedefs | |
| typedef gw_prioqueue | gw_prioqueue_t |
Functions | |
| gw_prioqueue_t * | gw_prioqueue_create (int(*cmp)(const void *, const void *)) |
| void | gw_prioqueue_destroy (gw_prioqueue_t *queue, void(*item_destroy)(void *)) |
| long | gw_prioqueue_len (gw_prioqueue_t *queue) |
| void | gw_prioqueue_insert (gw_prioqueue_t *queue, void *item) |
| void | gw_prioqueue_foreach (gw_prioqueue_t *queue, void(*fn)(const void *, long)) |
| void * | gw_prioqueue_remove (gw_prioqueue_t *queue) |
| void * | gw_prioqueue_get (gw_prioqueue_t *queue) |
| void * | gw_prioqueue_consume (gw_prioqueue_t *queue) |
| void | gw_prioqueue_add_producer (gw_prioqueue_t *queue) |
| void | gw_prioqueue_remove_producer (gw_prioqueue_t *queue) |
| long | gw_prioqueue_producer_count (gw_prioqueue_t *queue) |
|
|
Definition at line 66 of file gw-prioqueue.h. |
|
|
Definition at line 98 of file gw-prioqueue.h. Referenced by add_msg_cb(), at2_add_msg_cb(), clear_sent(), and emi2_idleprocessing(). |
|
|
|
Add producer to the priority queue - priority queue Definition at line 329 of file gw-prioqueue.c. References gw_assert, gw_prioqueue_t, gw_prioqueue::producers, queue_lock(), and queue_unlock(). 00330 {
00331 gw_assert(queue != NULL);
00332
00333 queue_lock(queue);
00334 queue->producers++;
00335 queue_unlock(queue);
00336 }
|
Here is the call graph for this function:

|
|
Remove biggest item from the priority queue, but block if producers available and none items in the queue - priority queue
Definition at line 303 of file gw-prioqueue.c. References downheap(), gw_assert, gw_prioqueue_t, gwthread_self(), element::item, gw_prioqueue::len, Mutex::mutex, gw_prioqueue::mutex, gw_prioqueue::nonempty, Mutex::owner, gw_prioqueue::producers, queue_lock(), queue_unlock(), and gw_prioqueue::tab. 00304 {
00305 void *ret;
00306
00307 gw_assert(queue != NULL);
00308
00309 queue_lock(queue);
00310 while (queue->len == 1 && queue->producers > 0) {
00311 queue->mutex->owner = -1;
00312 pthread_cond_wait(&queue->nonempty, &queue->mutex->mutex);
00313 queue->mutex->owner = gwthread_self();
00314 }
00315 if (queue->len > 1) {
00316 ret = queue->tab[1]->item;
00317 gw_free(queue->tab[1]);
00318 queue->tab[1] = queue->tab[--queue->len];
00319 downheap(queue, 1);
00320 } else {
00321 ret = NULL;
00322 }
00323 queue_unlock(queue);
00324
00325 return ret;
00326 }
|
Here is the call graph for this function:

|
|
Create priority queue - compare function
Definition at line 174 of file gw-prioqueue.c. References gw_assert, gw_prioqueue_t, make_bigger(), gw_prioqueue::mutex, mutex_create, and gw_prioqueue::producers. Referenced by main(), smsc_at2_create(), and smsc_emi2_create(). 00175 {
00176 gw_prioqueue_t *ret;
00177
00178 gw_assert(cmp != NULL);
00179
00180 ret = gw_malloc(sizeof(*ret));
00181 ret->producers = 0;
00182 pthread_cond_init(&ret->nonempty, NULL);
00183 ret->mutex = mutex_create();
00184 ret->tab = NULL;
00185 ret->size = 0;
00186 ret->len = 0;
00187 ret->seq = 0;
00188 ret->cmp = cmp;
00189
00190 /* put NULL item at pos 0 that is our stop marker */
00191 make_bigger(ret, 1);
00192 ret->tab[0] = gw_malloc(sizeof(**ret->tab));
00193 ret->tab[0]->item = NULL;
00194 ret->tab[0]->seq = ret->seq++;
00195 ret->len++;
00196
00197 return ret;
00198 }
|
Here is the call graph for this function:

|
||||||||||||
|
Destroy priority queue - queue to destroy - item destructor Definition at line 201 of file gw-prioqueue.c. References gw_prioqueue_t, element::item, item_destroy(), gw_prioqueue::len, gw_prioqueue::mutex, mutex_destroy(), gw_prioqueue::nonempty, and gw_prioqueue::tab. Referenced by at2_device_thread(), emi2_sender(), smsc_at2_create(), and smsc_emi2_create(). 00202 {
00203 long i;
00204
00205 if (queue == NULL)
00206 return;
00207
00208 for (i = 0; i < queue->len; i++) {
00209 if (item_destroy != NULL && queue->tab[i]->item != NULL)
00210 item_destroy(queue->tab[i]->item);
00211 gw_free(queue->tab[i]);
00212 }
00213 mutex_destroy(queue->mutex);
00214 pthread_cond_destroy(&queue->nonempty);
00215 gw_free(queue->tab);
00216 gw_free(queue);
00217 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 252 of file gw-prioqueue.c. References gw_assert, gw_prioqueue_t, element::item, gw_prioqueue::len, queue_lock(), queue_unlock(), and gw_prioqueue::tab. Referenced by main(). 00253 {
00254 register long i;
00255
00256 gw_assert(queue != NULL && fn != NULL);
00257
00258 queue_lock(queue);
00259 for (i = 1; i < queue->len; i++)
00260 fn(queue->tab[i]->item, i - 1);
00261 queue_unlock(queue);
00262 }
|
Here is the call graph for this function:

|
|
Definition at line 286 of file gw-prioqueue.c. References gw_assert, gw_prioqueue_t, element::item, gw_prioqueue::len, queue_lock(), queue_unlock(), and gw_prioqueue::tab. 00287 {
00288 void *ret;
00289
00290 gw_assert(queue != NULL);
00291
00292 queue_lock(queue);
00293 if (queue->len > 1)
00294 ret = queue->tab[1]->item;
00295 else
00296 ret = NULL;
00297 queue_unlock(queue);
00298
00299 return ret;
00300 }
|
Here is the call graph for this function:

|
||||||||||||
|
Insert item into the priority queue - priority queue - to be inserted item Definition at line 235 of file gw-prioqueue.c. References gw_assert, gw_prioqueue_t, element::item, gw_prioqueue::len, make_bigger(), gw_prioqueue::nonempty, queue_lock(), queue_unlock(), gw_prioqueue::seq, element::seq, gw_prioqueue::tab, and upheap(). Referenced by main(). 00236 {
00237 gw_assert(queue != NULL);
00238 gw_assert(item != NULL);
00239
00240 queue_lock(queue);
00241 make_bigger(queue, 1);
00242 queue->tab[queue->len] = gw_malloc(sizeof(**queue->tab));
00243 queue->tab[queue->len]->item = item;
00244 queue->tab[queue->len]->seq = queue->seq++;
00245 upheap(queue, queue->len);
00246 queue->len++;
00247 pthread_cond_signal(&queue->nonempty);
00248 queue_unlock(queue);
00249 }
|
Here is the call graph for this function:

|
|
Return priority queue length - priority queue
Definition at line 220 of file gw-prioqueue.c. References gw_prioqueue_t, gw_prioqueue::len, queue_lock(), and queue_unlock(). Referenced by at2_device_thread(), at2_queued_cb(), at2_send_messages(), emi2_wait(), main(), and queued_cb(). 00221 {
00222 long len;
00223
00224 if (queue == NULL)
00225 return 0;
00226
00227 queue_lock(queue);
00228 len = queue->len - 1;
00229 queue_unlock(queue);
00230
00231 return len;
00232 }
|
Here is the call graph for this function:

|
|
Return producer count for the priority queue - priority queue
Definition at line 351 of file gw-prioqueue.c. References gw_assert, gw_prioqueue_t, gw_prioqueue::producers, queue_lock(), and queue_unlock(). 00352 {
00353 long ret;
00354
00355 gw_assert(queue != NULL);
00356
00357 queue_lock(queue);
00358 ret = queue->producers;
00359 queue_unlock(queue);
00360
00361 return ret;
00362 }
|
Here is the call graph for this function:

|
|
Remove biggest item from the priority queue, but not block if producers available and none items in the queue - priority queue
Definition at line 265 of file gw-prioqueue.c. References downheap(), gw_assert, gw_prioqueue_t, element::item, gw_prioqueue::len, queue_lock(), queue_unlock(), and gw_prioqueue::tab. Referenced by at2_send_messages(), at2_shutdown_cb(), emi2_do_send(), emi2_sender(), main(), open_send_connection(), and shutdown_cb(). 00266 {
00267 void *ret;
00268
00269 gw_assert(queue != NULL);
00270
00271 queue_lock(queue);
00272 if (queue->len <= 1) {
00273 queue_unlock(queue);
00274 return NULL;
00275 }
00276 ret = queue->tab[1]->item;
00277 gw_free(queue->tab[1]);
00278 queue->tab[1] = queue->tab[--queue->len];
00279 downheap(queue, 1);
00280 queue_unlock(queue);
00281
00282 return ret;
00283 }
|
Here is the call graph for this function:

|
|
Remove producer from the priority queue - priority queue Definition at line 339 of file gw-prioqueue.c. References gw_assert, gw_prioqueue_t, gw_prioqueue::nonempty, gw_prioqueue::producers, queue_lock(), and queue_unlock(). 00340 {
00341 gw_assert(queue != NULL);
00342
00343 queue_lock(queue);
00344 gw_assert(queue->producers > 0);
00345 queue->producers--;
00346 pthread_cond_broadcast(&queue->nonempty);
00347 queue_unlock(queue);
00348 }
|
Here is the call graph for this function:
