Skip to content

Commit

Permalink
Migrate from lazy_static to once_cell.
Browse files Browse the repository at this point in the history
The Rust ecosystem is generally migrating away from lazy_static to
once_cell, for example [here].

This patch updates openvino-sys from lazy_static to once_cell.

[here]: clap-rs/clap#3828
  • Loading branch information
sunfishcode committed Jul 2, 2022
1 parent 086e7d3 commit 911d85f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/openvino-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include = [
links = "inference_engine_c_api"

[dependencies]
lazy_static = {version = "1.4", optional = true }
once_cell = {version = "1.12.0", optional = true }
libloading = {version = "0.7", optional = true }
openvino-finder = {version = "0.4.0", path = "../openvino-finder" }

Expand All @@ -36,7 +36,7 @@ pretty_env_logger = "0.4"
[features]
# Linking features: `build.rs` will default to dynamic linking if none is selected.
dynamic-linking = [] # Will find and bind to an OpenVINO shared library at compile time.
runtime-linking = ["libloading", "lazy_static"] # Will bind to an OpenVINO shared library at runtime using `load`.
runtime-linking = ["libloading", "once_cell"] # Will bind to an OpenVINO shared library at runtime using `load`.

[package.metadata.docs.rs]
features = ["runtime-linking"]
6 changes: 2 additions & 4 deletions crates/openvino-sys/src/linking/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ macro_rules! link {
}
)+
) => (
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use libloading;
use std::path::PathBuf;
use std::sync::Arc;
Expand All @@ -34,9 +34,7 @@ macro_rules! link {
}

// `LIBRARY` holds the shared library reference.
lazy_static!{
static ref LIBRARY: RwLock<Option<Arc<SharedLibrary>>> = RwLock::new(None);
}
static LIBRARY: Lazy<RwLock<Option<Arc<SharedLibrary>>>> = Lazy::new(|| RwLock::new(None));

// Helper function for accessing the thread-local version of the library.
fn with_library<T, F>(f: F) -> Option<T>
Expand Down

0 comments on commit 911d85f

Please sign in to comment.