liblttng-ctl: use export list to define exported symbols
[lttng-tools.git] / src / bin / lttng-relayd / tracefile-array.h
CommitLineData
a44ca2ca
MD
1#ifndef _TRACEFILE_ARRAY_H
2#define _TRACEFILE_ARRAY_H
3
4/*
ab5be9fa 5 * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
a44ca2ca 6 *
ab5be9fa 7 * SPDX-License-Identifier: GPL-2.0-only
a44ca2ca 8 *
a44ca2ca
MD
9 */
10
11#include <limits.h>
12#include <inttypes.h>
13#include <pthread.h>
14#include <stdbool.h>
15
16struct tracefile {
17 /* Per-tracefile head/tail seq. */
18 uint64_t seq_head; /* Newest seqcount. Inclusive. */
19 uint64_t seq_tail; /* Oldest seqcount. Inclusive. */
20};
21
78118e3b
MD
22enum tracefile_rotate_type {
23 TRACEFILE_ROTATE_READ,
24 TRACEFILE_ROTATE_WRITE,
25};
26
a44ca2ca
MD
27/*
28 * Represents an array of trace files in a stream.
78118e3b
MD
29 * head is the most recent file/trace packet.
30 * tail is the oldest file/trace packet.
31 *
32 * There are two heads: a "read" head and a "write" head. The "write" head is
33 * the position of the newest data file. The "read" head position is only moved
34 * forward when the index is received.
35 *
36 * The viewer uses the "read" head position as upper bound, which
37 * ensures it never attempts to open a non-existing index file.
a44ca2ca
MD
38 */
39struct tracefile_array {
40 struct tracefile *tf;
41 size_t count;
42
43 /* Current head/tail files. */
78118e3b
MD
44 uint64_t file_head_read;
45 uint64_t file_head_write;
a44ca2ca
MD
46 uint64_t file_tail;
47
48 /* Overall head/tail seq for the entire array. Inclusive. */
49 uint64_t seq_head;
50 uint64_t seq_tail;
51};
52
53struct tracefile_array *tracefile_array_create(size_t count);
54void tracefile_array_destroy(struct tracefile_array *tfa);
55
78118e3b 56void tracefile_array_file_rotate(struct tracefile_array *tfa, enum tracefile_rotate_type type);
62f6e9ef
MD
57void tracefile_array_commit_seq(struct tracefile_array *tfa,
58 uint64_t new_seq_head);
c31a8092 59void tracefile_array_reset(struct tracefile_array *tfa);
a44ca2ca 60
78118e3b 61uint64_t tracefile_array_get_read_file_index_head(struct tracefile_array *tfa);
a44ca2ca
MD
62/* May return -1ULL in the case where we have not received any indexes yet. */
63uint64_t tracefile_array_get_seq_head(struct tracefile_array *tfa);
64
65uint64_t tracefile_array_get_file_index_tail(struct tracefile_array *tfa);
66/* May return -1ULL in the case where we have not received any indexes yet. */
67uint64_t tracefile_array_get_seq_tail(struct tracefile_array *tfa);
68
69bool tracefile_array_seq_in_file(struct tracefile_array *tfa,
70 uint64_t file_index, uint64_t seq);
71
72#endif /* _STREAM_H */
This page took 0.042711 seconds and 4 git commands to generate.