Skip to content

Commit

Permalink
changed lazy_static to once_cell
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBeilschmidt committed Sep 7, 2021
1 parent 8b609cc commit da4c2ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gdal-sys = { path = "gdal-sys", version = "^0.5"}
ndarray = {version = "0.15", optional = true }
chrono = { version = "0.4", optional = true }
bitflags = "1.2"
lazy_static = "1.3"
once_cell = "1.8"

[build-dependencies]
gdal-sys = { path = "gdal-sys", version= "^0.5"}
Expand Down
9 changes: 4 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use libc::{c_char, c_void};

use crate::errors::Result;
use crate::utils::_string;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use std::ffi::CString;
use std::sync::Mutex;

Expand Down Expand Up @@ -127,10 +127,9 @@ type CallbackType = dyn FnMut(CplErr, i32, &str) + 'static;
static mut ERROR_CALLBACK: Option<Box<CallbackType>> = None;

type CallbackTypeThreadSafe = dyn FnMut(CplErr, i32, &str) + 'static + Send;
lazy_static! {
static ref ERROR_CALLBACK_THREAD_SAFE: Mutex<Option<Box<CallbackTypeThreadSafe>>> =
Mutex::new(None);
}

static ERROR_CALLBACK_THREAD_SAFE: Lazy<Mutex<Option<Box<CallbackTypeThreadSafe>>>> =
Lazy::new(Default::default);

/// Set a custom error handler for GDAL.
/// Could be overwritten by setting a thread-local error handler.
Expand Down

0 comments on commit da4c2ac

Please sign in to comment.