source: lib/data-struct/deque.h @ 6a082f8

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

Tidies up the pausing so that it now works as expected and a trace can easily be paused and restarted.
Ensures that packets will not be lost if pause is called on a file, any queued packets will be read (a message is sent allowing the user to drop these packets if they are unwanted).
Differentiates packets from other results in the queues to the reducer/reporter and makes a copy of the packets in result queues when pausing

  • this is needed to ensure that bad memory isn't referenced if a zero-copy trace is paused by closing sockets/associated data like in the case of ring:.

Fixed up the re-starting of traces which hadn't been finished to account for different configurations.
Adds a 'state' to libtrace to handle the state of parallel traces, rather than hacking around the existing 'started' boolean. Also provides two levels of checks for consistency if the trace is using existing that are checking started.

Various other bug fixes and tidy ups.

  • Property mode set to 100644
File size: 1.1 KB
1#include <pthread.h>
2#include "../libtrace.h"
7typedef struct list_node list_node_t;
8typedef void (*deque_data_fn)(void *data);
9typedef struct libtrace_queue {
10        list_node_t * head;
11        list_node_t * tail;
12        pthread_mutex_t lock;
13        size_t size;
14        size_t element_size;
15} libtrace_queue_t;
17DLLEXPORT void libtrace_deque_init(libtrace_queue_t * q, size_t element_size);
18DLLEXPORT void libtrace_deque_push_back(libtrace_queue_t *q, void *d);
19DLLEXPORT void libtrace_deque_push_front(libtrace_queue_t *q, void *d);
20DLLEXPORT size_t libtrace_deque_get_size(libtrace_queue_t *q);
22DLLEXPORT int libtrace_deque_peek_front(libtrace_queue_t *q, void *d);
23DLLEXPORT int libtrace_deque_peek_tail(libtrace_queue_t *q, void *d);
24DLLEXPORT int libtrace_deque_pop_front(libtrace_queue_t *q, void *d);
25DLLEXPORT int libtrace_deque_pop_tail(libtrace_queue_t *q, void *d);
26DLLEXPORT void libtrace_zero_deque(libtrace_queue_t *q);
28// Apply a given function to every data item, while keeping the entire
29// structure locked from external modifications
30DLLEXPORT void libtrace_deque_apply_function(libtrace_queue_t *q, deque_data_fn fn);
Note: See TracBrowser for help on using the repository browser.