GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/ingestion/task_read.h
Date: 2024-04-21 02:33:16
Exec Total Coverage
Lines: 8 8 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 "ingestion/item.h"
11 #include "ingestion/task.h"
12 #include "util/atomic.h"
13 #include "util/posix.h"
14 #include "util/tube.h"
15
16 class ItemAllocator;
17
18 class TaskRead : public TubeConsumer<FileItem> {
19 public:
20 static const unsigned kThrottleInitMs = 50;
21 static const unsigned kThrottleMaxMs = 500;
22 static const unsigned kThrottleResetMs = 2000;
23 static const unsigned kBlockSize = kPageSize * 4;
24
25 2818 TaskRead(
26 Tube<FileItem> *tube_in,
27 TubeGroup<BlockItem> *tubes_out,
28 ItemAllocator *allocator)
29 2818 : TubeConsumer<FileItem>(tube_in)
30 2818 , tubes_out_(tubes_out)
31 2818 , allocator_(allocator)
32 2818 , low_watermark_(0)
33 2818 , high_watermark_(0)
34 2818 { atomic_init64(&n_block_); }
35
36 void SetWatermarks(uint64_t low, uint64_t high);
37
38 3 uint64_t n_block() { return atomic_read64(&n_block_); }
39
40 protected:
41 virtual void Process(FileItem *item);
42
43 private:
44 /**
45 * Every new file increases the tag sequence counter that is used to annotate
46 * BlockItems.
47 */
48 static atomic_int64 tag_seq_;
49
50 TubeGroup<BlockItem> *tubes_out_;
51 ItemAllocator *allocator_;
52 /**
53 * Continue reading once the amount of BlockItem managed bytes is back to
54 * the given level.
55 */
56 uint64_t low_watermark_;
57 /**
58 * Stop reading new data into the pipeline when the amount BlockItem managed
59 * byte is higher than the given level.
60 */
61 uint64_t high_watermark_;
62 /**
63 * Number of times reading was blocked on a high watermark.
64 */
65 atomic_int64 n_block_;
66 };
67
68 #endif // CVMFS_INGESTION_TASK_READ_H_
69