libklvanc
Loading...
Searching...
No Matches
cache.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Kernel Labs Inc. All Rights Reserved
3 *
4 * Address: Kernel Labs Inc., PO Box 745, St James, NY. 11780
5 * Contact: sales@kernellabs.com
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
28
29#ifndef _VANC_CACHE_H
30#define _VANC_CACHE_H
31
32#include <pthread.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
39{
40 int active;
41 uint64_t count;
42 struct klvanc_packet_header_s *pkt;
43};
44
46{
47 uint32_t did, sdid;
48 const char *desc, *spec;
49 struct timeval lastUpdated;
50 int hasCursor;
51 int expandUI;
52 int save;
53 uint32_t activeCount;
54 /* Guards every field below it (activeCount, and each line's active/
55 count/pkt) against concurrent klvanc_cache_update()/_reset()/
56 lookup-and-read calls. One mutex per did/sdid entry rather than
57 one per line: with 0x10000 possible did/sdid entries, a per-line
58 mutex (2048 lines each) would mean over 130 million pthread_mutex_t
59 objects and, at ~64 bytes apiece on some platforms, multiple
60 gigabytes just for locks. Callers that need to read a line's
61 fields (e.g. via klvanc_cache_lookup()) while update()/reset() may
62 be running concurrently on another thread must hold this mutex for
63 the duration of that read -- see klvanc_cache_lookup()'s doc
64 comment. */
65 pthread_mutex_t mutex;
66 struct klvanc_cache_line_s lines[2048];
67};
68
77
86
94struct klvanc_cache_s * klvanc_cache_lookup(struct klvanc_context_s *ctx, uint8_t didnr, uint8_t sdidnr);
95
96#ifdef __cplusplus
97};
98#endif
99
100#endif /* _VANC_CACHE_H */
struct klvanc_cache_s * klvanc_cache_lookup(struct klvanc_context_s *ctx, uint8_t didnr, uint8_t sdidnr)
When caching and summarizing VANC payload is enabled, lookup any statistics related to didnr and sdid...
void klvanc_cache_reset(struct klvanc_context_s *ctx)
When caching and summarizing VANC payload is enabled, use this to reset any internal counters,...
int klvanc_context_enable_cache(struct klvanc_context_s *ctx)
Begin caching and summarizing VANC payload, useful when you want to query what VANC messages,...
Definition cache.h:39
Definition cache.h:46
Application specific context, the library allocates and stores user specific instance information.
Definition vanc.h:125
TODO - Brief description goes here.
Definition vanc-packets.h:59