From aa8222e955634233c26bd8cac7a48f5aec0311d8 Mon Sep 17 00:00:00 2001 From: dahlend Date: Tue, 15 Oct 2024 07:34:03 -0700 Subject: [PATCH] PCK switch to ShardedLock --- src/kete_core/src/spice/pck.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/kete_core/src/spice/pck.rs b/src/kete_core/src/spice/pck.rs index 8e9c55a..c25d5fd 100644 --- a/src/kete_core/src/spice/pck.rs +++ b/src/kete_core/src/spice/pck.rs @@ -9,10 +9,11 @@ use super::daf::{DAFType, DafFile}; use super::pck_segments::PckSegment; use crate::errors::{Error, NeosResult}; use crate::frames::Frame; +use crossbeam::sync::ShardedLock; use std::io::Cursor; use std::mem::MaybeUninit; -use std::sync::{Once, RwLock}; +use std::sync::Once; const PRELOAD_PCK: &[&[u8]] = &[ include_bytes!("../../data/earth_000101_240215_231123.bpc"), @@ -27,7 +28,7 @@ pub struct PckCollection { } /// Define the PCK singleton structure. -pub type PckSingleton = RwLock; +pub type PckSingleton = ShardedLock; impl PckCollection { /// Given an PCK filename, load all the segments present inside of it. @@ -91,7 +92,7 @@ pub fn get_pck_singleton() -> &'static PckSingleton { segments: Vec::new(), }; files.reset(); - let singleton: PckSingleton = RwLock::new(files); + let singleton: PckSingleton = ShardedLock::new(files); // Store it to the static var, i.e. initialize it let _ = SINGLETON.write(singleton); });