Skip to content

Commit

Permalink
Merge pull request #212 from muzarski/use-lazy-lock
Browse files Browse the repository at this point in the history
lib: migrate to stable `LazyLock`
  • Loading branch information
muzarski authored Dec 3, 2024
2 parents f1ed076 + fb85689 commit 81e668e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions scylla-rust-wrapper/Cargo.lock

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

1 change: 0 additions & 1 deletion scylla-rust-wrapper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ scylla = { git = "https://github.com/scylladb/scylla-rust-driver.git", rev = "v0
"ssl",
] }
tokio = { version = "1.27.0", features = ["full"] }
lazy_static = "1.4.0"
uuid = "1.1.2"
machine-uid = "0.2.0"
rand = "0.8.4"
Expand Down
12 changes: 6 additions & 6 deletions scylla-rust-wrapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::logging::stderr_log_callback;
use crate::logging::Logger;
use lazy_static::lazy_static;
use std::sync::LazyLock;
use std::sync::RwLock;
use tokio::runtime::Runtime;

Expand Down Expand Up @@ -110,13 +110,13 @@ pub mod cass_uuid_types {
include_bindgen_generated!("cppdriver_uuid_types.rs");
}

lazy_static! {
pub static ref RUNTIME: Runtime = Runtime::new().unwrap();
pub static ref LOGGER: RwLock<Logger> = RwLock::new(Logger {
pub static RUNTIME: LazyLock<Runtime> = LazyLock::new(|| Runtime::new().unwrap());
pub static LOGGER: LazyLock<RwLock<Logger>> = LazyLock::new(|| {
RwLock::new(Logger {
cb: Some(stderr_log_callback),
data: std::ptr::null_mut(),
});
}
})
});

// To send a Rust object to C:

Expand Down

0 comments on commit 81e668e

Please sign in to comment.