Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCK switch to ShardedLock #138

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/kete_core/src/spice/pck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -27,7 +28,7 @@ pub struct PckCollection {
}

/// Define the PCK singleton structure.
pub type PckSingleton = RwLock<PckCollection>;
pub type PckSingleton = ShardedLock<PckCollection>;

impl PckCollection {
/// Given an PCK filename, load all the segments present inside of it.
Expand Down Expand Up @@ -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);
});
Expand Down