common: compile libconsumer, libust-consumer, libkernel-consumer as C++
[lttng-tools.git] / src / common / consumer / consumer-metadata-cache.h
CommitLineData
331744e3 1/*
ab5be9fa
MJ
2 * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
3 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
331744e3 4 *
ab5be9fa 5 * SPDX-License-Identifier: GPL-2.0-only
331744e3 6 *
331744e3
JD
7 */
8
9#ifndef CONSUMER_METADATA_CACHE_H
10#define CONSUMER_METADATA_CACHE_H
11
c8fea79c 12#include <common/consumer/consumer.h>
9eac9828 13#include <common/dynamic-buffer.h>
331744e3 14
97535efa
SM
15#ifdef __cplusplus
16extern "C" {
17#endif
18
b1316da1
JG
19enum consumer_metadata_cache_write_status {
20 CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR = -1,
21 /*
22 * New metadata content was appended to the cache successfully.
23 * Previously available content remains valid.
24 */
25 CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT = 0,
26 /*
27 * The new content pushed to the cache invalidated the content that
28 * was already present. The contents of the cache should be re-read.
29 */
30 CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED,
31 /*
32 * A metadata cache write can simply overwrite an already existing
33 * section of the cache (and it should be a write-through with identical
34 * data). From the caller's standpoint, there is no change to the state
35 * of the cache.
36 */
37 CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE,
38};
39
331744e3 40struct consumer_metadata_cache {
9eac9828 41 /* Current version of the metadata cache. */
93ec662e 42 uint64_t version;
331744e3 43 /*
9eac9828 44 * Size is the upper-limit of data written inside the buffer.
c585821b 45 * All cached data is contiguous.
331744e3 46 */
9eac9828 47 struct lttng_dynamic_buffer contents;
331744e3
JD
48 /*
49 * Lock to update the metadata cache and push into the ring_buffer
b623cb6a 50 * (lttng_ust_ctl_write_metadata_to_channel).
73811ecc
DG
51 *
52 * This is nested INSIDE the consumer_data lock.
331744e3
JD
53 */
54 pthread_mutex_t lock;
55};
56
b1316da1 57enum consumer_metadata_cache_write_status
a25d34bc 58consumer_metadata_cache_write(struct consumer_metadata_cache *cache,
93ec662e 59 unsigned int offset, unsigned int len, uint64_t version,
d44f9a18 60 const char *data);
331744e3
JD
61int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel);
62void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel);
63int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
5e41ebe1 64 uint64_t offset, int timer);
331744e3 65
97535efa
SM
66#ifdef __cplusplus
67}
68#endif
69
331744e3 70#endif /* CONSUMER_METADATA_CACHE_H */
This page took 0.05483 seconds and 4 git commands to generate.