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

Method close

engine/src/ngram/ple_reader.cpp:392–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392void PleReader::close() {
393 Impl& m = *impl_;
394 if (m.worker.joinable()) {
395 {
396 std::lock_guard<std::mutex> lk(m.mu);
397 m.stop = true;
398 m.queue.clear(); // unsubmitted work is dropped; in-flight reads still drain
399 }
400 m.cv_work.notify_all();
401 m.file.wake();
402 m.worker.join();
403 }
404 // Outstanding reads must finish before their buffers are released (caller-thread mode, or a worker that
405 // stopped on an error).
406 if (m.file.is_open()) {
407 while (m.free_slots.size() < m.max_inflight) {
408 Completion c[64];
409 const int n = m.file.wait(c, 64, -1);
410 if (n == 0) break;
411 for (int i = 0; i < n; ++i)
412 if (c[i].tag != DirectFile::WAKE_TAG) m.free_slots.push_back((uint32_t) c[i].tag);
413 }
414 }
415 m.file.close();
416 DirectFile::free_aligned(m.slab);
417 m.slab = nullptr;
418 m.queue.clear();
419 m.tickets.clear();
420 m.delayed.clear();
421 m.inflight.clear();
422 m.free_slots.clear();
423 m.cache.init(0);
424 m.threaded = false;
425 m.stop = false;
426 m.keep_us = 0;
427 m.last_issue_us = m.last_read_us = 0;
428}
429
430bool PleReader::is_open() const { return impl_->file.is_open(); }
431uint32_t PleReader::row_bytes() const { return impl_->row_bytes; }

Callers 7

write_format_tableFunction · 0.45
write_fixture_ggufFunction · 0.45
run_configFunction · 0.45
error_does_not_hangFunction · 0.45
big_offsetsFunction · 0.45
mainFunction · 0.45

Calls 9

push_backMethod · 0.80
clearMethod · 0.45
notify_allMethod · 0.45
wakeMethod · 0.45
joinMethod · 0.45
is_openMethod · 0.45
sizeMethod · 0.45
waitMethod · 0.45
initMethod · 0.45

Tested by 7

write_format_tableFunction · 0.36
write_fixture_ggufFunction · 0.36
run_configFunction · 0.36
error_does_not_hangFunction · 0.36
big_offsetsFunction · 0.36
mainFunction · 0.36