Spawn a background HNSW builder thread for a Data Plane core.
(core_id: usize)
| 21 | |
| 22 | /// Spawn a background HNSW builder thread for a Data Plane core. |
| 23 | pub fn spawn_builder(core_id: usize) -> (BuildSender, CompleteReceiver, JoinHandle<()>) { |
| 24 | let (request_tx, request_rx) = mpsc::channel::<BuildRequest>(); |
| 25 | let (complete_tx, complete_rx) = mpsc::channel::<BuildComplete>(); |
| 26 | |
| 27 | let handle = std::thread::Builder::new() |
| 28 | .name(format!("hnsw-builder-{core_id}")) |
| 29 | .spawn(move || { |
| 30 | info!(core_id, "HNSW builder thread started"); |
| 31 | builder_loop(core_id, request_rx, complete_tx); |
| 32 | info!(core_id, "HNSW builder thread stopped"); |
| 33 | }) |
| 34 | .expect("failed to spawn HNSW builder thread"); |
| 35 | |
| 36 | (request_tx, complete_rx, handle) |
| 37 | } |
| 38 | |
| 39 | fn builder_loop(core_id: usize, rx: mpsc::Receiver<BuildRequest>, tx: mpsc::Sender<BuildComplete>) { |
| 40 | while let Ok(req) = rx.recv() { |
nothing calls this directly
no test coverage detected