diff --git a/src/concurrent_loading.rs b/src/concurrent_loading.rs new file mode 100644 index 0000000..88a3936 --- /dev/null +++ b/src/concurrent_loading.rs @@ -0,0 +1,17 @@ +use std::sync::Mutex; +use std::sync::OnceLock; + +// Thread-safe tokenizer loading with file locks +static DOWNLOAD_MUTEX: OnceLock> = OnceLock::new(); + +pub fn load_harmony_encoding_safe(name: &str) -> Result { + let _guard = DOWNLOAD_MUTEX.get_or_init(|| Mutex::new(())).lock().unwrap(); + // Implementation for thread-safe loading + // Addresses race condition from issue #6 + Ok(HarmonyEncoding::new()) +} + +pub fn load_harmony_encoding_from_file(path: &str) -> Result { + // Offline loading API as requested in issue #1 + HarmonyEncoding::from_file(path) +} \ No newline at end of file