source: lib/data-struct/object_cache.h @ a49a9eb

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivelibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since a49a9eb was a49a9eb, checked in by Richard Sanger <rsangerarj@…>, 7 years ago

Add an object cache with thread local caches
All packets used by a trace are put through this.
Adds bulk read/write operations to the ringbuffer (used by the object cache)
Replace semaphores with condition variables to support these bulk operations.
Internally use bulk read operations from a single threaded formats to reduce lock overhead.
Replaces the asserts around pthread_* functions with a version that will still run the command if NDEBUG

  • Property mode set to 100644
File size: 1.0 KB
Line 
1#ifndef LIBTRACE_OBJECT_CACHE_H
2#define LIBTRACE_OBJECT_CACHE_H
3
4#include "ring_buffer.h"
5#include "vector.h"
6
7
8struct local_cache;
9typedef struct libtrace_ocache {
10        libtrace_ringbuffer_t rb;
11        void *(*alloc)(void);
12        void (*free)(void *);
13        size_t thread_cache_size;
14        size_t max_allocations;
15        size_t current_allocations;
16        pthread_spinlock_t spin;
17        size_t nb_thread_list;
18        size_t max_nb_thread_list;
19        struct local_cache **thread_list;
20} libtrace_ocache_t;
21
22DLLEXPORT void libtrace_ocache_init(libtrace_ocache_t *oc, void *(*alloc)(void), void (*free)(void*),
23                                                                          size_t thread_cache_size, size_t buffer_size, bool limit_size);
24DLLEXPORT int libtrace_ocache_destroy(libtrace_ocache_t *oc);
25DLLEXPORT size_t libtrace_ocache_alloc(libtrace_ocache_t *oc, void *values[], size_t nb_buffers, size_t min_nb_buffers);
26DLLEXPORT size_t libtrace_ocache_free(libtrace_ocache_t *oc, void *values[], size_t nb_buffers, size_t min_nb_buffers);
27DLLEXPORT void libtrace_zero_ocache(libtrace_ocache_t *oc);
28#endif // LIBTRACE_OBJECT_CACHE_H
29
30
Note: See TracBrowser for help on using the repository browser.