source: lib/data-struct/deque.h @ 10553bf

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivelibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 10553bf was fac8c46, checked in by Richard Sanger <rsangerarj@…>, 8 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
RevLine 
[29bbef0]1#include <pthread.h>
[ead9478]2#include "../libtrace.h"
[29bbef0]3
[d6a56b6]4#ifndef LIBTRACE_DEQUE_H
5#define LIBTRACE_DEQUE_H
[29bbef0]6
7typedef struct list_node list_node_t;
[fac8c46]8typedef void (*deque_data_fn)(void *data);
[29bbef0]9typedef struct libtrace_queue {
10        list_node_t * head;
11        list_node_t * tail;
12        pthread_mutex_t lock;
[ead9478]13        size_t size;
14        size_t element_size;
[29bbef0]15} libtrace_queue_t;
16
[ead9478]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);
[29bbef0]21
[ead9478]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);
[29bbef0]27
[fac8c46]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);
31
[29bbef0]32#endif
Note: See TracBrowser for help on using the repository browser.