GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/ingestion/task_read.h
Date: 2026-10-11 02:40:02
Exec Total Coverage
Lines: 9 9 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_INGESTION_TASK_READ_H_
6 #define CVMFS_INGESTION_TASK_READ_H_
7
8 #include <stdint.h>
9
10 #include <atomic>
11
12 #include "ingestion/item.h"
13 #include "ingestion/task.h"
14 #include "util/posix.h"
15 #include "util/tube.h"
16
17 class ItemAllocator;
18
19 class TaskRead : public TubeConsumer<FileItem> {
20 public:
21 static const unsigned kThrottleInitMs = 50;
22 static const unsigned kThrottleMaxMs = 500;
23 static const unsigned kThrottleResetMs = 2000;
24 static const unsigned kBlockSize = kPageSize * 4;
25
26 68886 TaskRead(Tube<FileItem> *tube_in,
27 TubeGroup<BlockItem> *tubes_out,
28 ItemAllocator *allocator)
29 68886 : TubeConsumer<FileItem>(tube_in)
30 68886 , tubes_out_(tubes_out)
31 68886 , allocator_(allocator)
32 68886 , low_watermark_(0)
33 68886 , high_watermark_(0) {
34 68886 n_block_.store(0);
35 68886 }
36
37 void SetWatermarks(uint64_t low, uint64_t high);
38
39 258 uint64_t n_block() { return n_block_.load(); }
40
41 protected:
42 virtual void Process(FileItem *item);
43
44 private:
45 /**
46 * Every new file increases the tag sequence counter that is used to annotate
47 * BlockItems.
48 */
49 static std::atomic<int64_t> tag_seq_;
50
51 TubeGroup<BlockItem> *tubes_out_;
52 ItemAllocator *allocator_;
53 /**
54 * Continue reading once the amount of BlockItem managed bytes is back to
55 * the given level.
56 */
57 uint64_t low_watermark_;
58 /**
59 * Stop reading new data into the pipeline when the amount BlockItem managed
60 * byte is higher than the given level.
61 */
62 uint64_t high_watermark_;
63 /**
64 * Number of times reading was blocked on a high watermark.
65 */
66 std::atomic<int64_t> n_block_;
67 };
68
69 #endif // CVMFS_INGESTION_TASK_READ_H_
70