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

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivelibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since d994324 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
Line 
1#include <pthread.h>
2/* Need libtrace.h for DLLEXPORT defines */
3#include "../libtrace.h"
4
5#ifndef LIBTRACE_VECTOR_H
6#define LIBTRACE_VECTOR_H
7
8typedef void (*vector_data_fn)(void *data);
9struct libtrace_vector {
10        size_t max_size;
11        size_t size;
12        size_t element_size;
13        char *elements; // Means we can use array indexing
14        pthread_mutex_t lock;
15};
16
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);
26
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);
31
32// Sort the vector using qsort
33DLLEXPORT void libtrace_vector_qsort(libtrace_vector_t *v, int (*compar)(const void *, const void*));
34#endif
Note: See TracBrowser for help on using the repository browser.