• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dedicate-project / beast / 8c849f2c-086d-406b-a03d-7ef8df12cdc1

pending completion
8c849f2c-086d-406b-a03d-7ef8df12cdc1

Pull #9

circleci

fairlight1337
Fixed more code smells
Pull Request #9: Adding pipeline applications

1247 of 1247 new or added lines in 23 files covered. (100.0%)

2868 of 3092 relevant lines covered (92.76%)

16138.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.69
/src/pipe.cpp
1
#include <beast/pipe.hpp>
2

3
// Standard
4
#include <stdexcept>
5

6
namespace beast {
7

8
Pipe::Pipe(uint32_t max_candidates, uint32_t input_slots, uint32_t output_slots)
54✔
9
    : max_candidates_{max_candidates} {
54✔
10
  inputs_.resize(input_slots);
54✔
11
  outputs_.resize(output_slots);
54✔
12
}
54✔
13

14
void Pipe::addInput(uint32_t slot_index, const std::vector<unsigned char>& candidate) {
742✔
15
  std::scoped_lock lock(inputs_mutex_);
1,484✔
16
  inputs_[slot_index].push_back(candidate);
742✔
17
}
742✔
18

19
bool Pipe::inputHasSpace(uint32_t slot_index) {
711✔
20
  std::scoped_lock lock(inputs_mutex_);
711✔
21
  return inputs_[slot_index].size() < max_candidates_;
1,422✔
22
}
23

24
std::vector<unsigned char> Pipe::drawInput(uint32_t slot_index) {
714✔
25
  std::scoped_lock lock(inputs_mutex_);
1,428✔
26
  if (inputs_[slot_index].empty()) {
714✔
27
    throw std::underflow_error("No input candidates available to draw.");
1✔
28
  }
29

30
  std::vector<unsigned char> item = inputs_[slot_index].front();
713✔
31
  inputs_[slot_index].pop_front();
713✔
32

33
  return item;
1,426✔
34
}
35

36
bool Pipe::hasOutput(uint32_t slot_index) {
64✔
37
  std::scoped_lock lock(outputs_mutex_);
64✔
38
  return !outputs_[slot_index].empty();
128✔
39
}
40

41
Pipe::OutputItem Pipe::drawOutput(uint32_t slot_index) {
51✔
42
  std::scoped_lock lock(outputs_mutex_);
102✔
43
  if (outputs_[slot_index].empty()) {
51✔
44
    throw std::underflow_error("No output candidates available to draw.");
1✔
45
  }
46

47
  OutputItem item = std::move(outputs_[slot_index].front());
50✔
48
  outputs_[slot_index].erase(outputs_[slot_index].begin());
50✔
49

50
  return item;
100✔
51
}
52

53
uint32_t Pipe::getInputSlotAmount(uint32_t slot_index) {
10✔
54
  std::scoped_lock lock(inputs_mutex_);
10✔
55
  return static_cast<uint32_t>(inputs_[slot_index].size());
20✔
56
}
57

58
uint32_t Pipe::getOutputSlotAmount(uint32_t slot_index) {
14✔
59
  std::scoped_lock lock(outputs_mutex_);
14✔
60
  return static_cast<uint32_t>(outputs_[slot_index].size());
28✔
61
}
62

63
uint32_t Pipe::getInputSlotCount() const { return static_cast<uint32_t>(inputs_.size()); }
5✔
64

65
uint32_t Pipe::getOutputSlotCount() const { return static_cast<uint32_t>(outputs_.size()); }
4✔
66

67
uint32_t Pipe::getMaxCandidates() const { return max_candidates_; }
30✔
68

69
bool Pipe::inputsAreSaturated() {
2✔
70
  std::scoped_lock lock(inputs_mutex_);
4✔
71
  for (uint32_t idx = 0; idx < getInputSlotCount(); ++idx) {
3✔
72
    if (static_cast<uint32_t>(inputs_[idx].size()) < max_candidates_) {
2✔
73
      return false;
1✔
74
    }
75
  }
76
  return true;
1✔
77
}
78

79
bool Pipe::outputsAreSaturated() {
2✔
80
  const uint32_t outputSlotCount = getOutputSlotCount();
2✔
81
  if (outputSlotCount == 0) {
2✔
82
    return false;
×
83
  }
84
  std::scoped_lock lock(outputs_mutex_);
4✔
85
  for (uint32_t idx = 0; idx < outputSlotCount; ++idx) {
3✔
86
    if (static_cast<uint32_t>(outputs_[idx].size()) < max_candidates_) {
2✔
87
      return false;
1✔
88
    }
89
  }
90
  return true;
1✔
91
}
92

93
void Pipe::storeOutput(uint32_t slot_index, const OutputItem& output) {
×
94
  std::scoped_lock lock(outputs_mutex_);
×
95
  if (slot_index >= outputs_.size()) {
×
96
    throw std::invalid_argument("Slot index for output too large");
×
97
  }
98
  outputs_[slot_index].push_back(output);
×
99
}
×
100

101
void Pipe::storeOutput(uint32_t slot_index, OutputItem&& output) {
75✔
102
  std::scoped_lock lock(outputs_mutex_);
150✔
103
  if (slot_index >= outputs_.size()) {
75✔
104
    throw std::invalid_argument("Slot index for output too large");
×
105
  }
106
  outputs_[slot_index].push_back(std::move(output));
75✔
107
}
75✔
108

109
} // namespace beast
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc