MCPcopy Create free account
hub / github.com/Niko1221/Strata / wait_for_ram

Function wait_for_ram

engine/src/core/expert_source.cpp:146–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146bool wait_for_ram(uint64_t need, double max_wait_s, double step_s, double note_s,
147 const std::function<bool(uint64_t&)>& sample, const std::function<void(double)>& sleep,
148 const std::function<void(double, uint64_t)>& progress, double& waited, uint64_t& available) {
149 waited = 0.0;
150 if (!sample(available)) return false;
151 double next_note = 0.0;
152 while (available < need && waited < max_wait_s) {
153 if (progress && waited >= next_note) {
154 progress(waited, available);
155 next_note = waited + note_s;
156 }
157 sleep(step_s);
158 waited += step_s;
159 if (!sample(available)) return false;
160 }
161 return available >= need;
162}
163
164bool pin_step_fits(uint64_t available, uint64_t step, uint64_t reserve) {
165 return available >= step + reserve;

Callers 2

openMethod · 0.85
test_wait_for_ramFunction · 0.85

Calls 3

sampleFunction · 0.70
progressFunction · 0.50
sleepFunction · 0.50

Tested by 1

test_wait_for_ramFunction · 0.68