source: lib/data-struct/vector.h @ 2498008

Last change on this file since 2498008 was 2498008, checked in by Richard Sanger <rsangerarj@…>, 7 years ago

Refactor the combining step to allow user defined functions here.

Remove the old trace_get_results, now instead simply provide a reporter function which gets called as soon as results are ready.
The combiner function used determines the order of these results and when they are released etc.
The combiner function can be selected from those built-in or a custom version can be defined results are provided when ready.
Quickly hacked the parallel tests to work with this update, these are still a bit messy.

Also some fixes some compile warnings.

  • Property mode set to 100644
File size: 1.3 KB
[29bbef0]1#include <pthread.h>
[d6a56b6]2/* Need libtrace.h for DLLEXPORT defines */
3#include "../libtrace.h"
[d6a56b6]5#ifndef LIBTRACE_VECTOR_H
[fac8c46]8typedef void (*vector_data_fn)(void *data);
[8c42377]9struct libtrace_vector {
[ead9478]10        size_t max_size;
11        size_t size;
12        size_t element_size;
[29bbef0]13        char *elements; // Means we can use array indexing
14        pthread_mutex_t lock;
[abda273]17DLLEXPORT void libtrace_vector_init(libtrace_vector_t *v, size_t element_size);
18DLLEXPORT void libtrace_vector_push_back(libtrace_vector_t *v, void *d);
19DLLEXPORT size_t libtrace_vector_get_size(libtrace_vector_t *v);
20DLLEXPORT int libtrace_vector_get(libtrace_vector_t *v, size_t location, void *d);
21DLLEXPORT void libtrace_vector_append(libtrace_vector_t *dest, libtrace_vector_t *src);
22DLLEXPORT void libtrace_vector_destroy(libtrace_vector_t *v);
23DLLEXPORT void libtrace_zero_vector(libtrace_vector_t *v);
24DLLEXPORT int libtrace_vector_remove_front(libtrace_vector_t *v);
25DLLEXPORT void libtrace_vector_empty(libtrace_vector_t *v);
27// For now this is a special case and this doesn't really belong
28// here, but to do this properly a full lock is required as
29// multiple items are changed
30DLLEXPORT void libtrace_vector_apply_function(libtrace_vector_t *v, vector_data_fn fn);
[2498008]32// Sort the vector using qsort
33DLLEXPORT void libtrace_vector_qsort(libtrace_vector_t *v, int (*compar)(const void *, const void*));
Note: See TracBrowser for help on using the repository browser.