Skip to content

Commit

Permalink
refactor/features: replace StaticMutex
Browse files Browse the repository at this point in the history
Replace StaticMutex by the stable `lazy_static!`
  • Loading branch information
skade committed Dec 1, 2015
1 parent 872125a commit 6556934
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ rblas = "0.0.10"
enum_primitive = "0.1.0"
byteorder = "0.4"
num = "0.1"
lazy_static = "0.1.15"

clippy = { version = "0.0.27", optional = true }

Expand Down
6 changes: 4 additions & 2 deletions src/frameworks/opencl/api/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::types as cl;
use super::ffi::*;
use std::ptr;
use std::iter::repeat;
use std::sync::{StaticMutex, MUTEX_INIT};
use std::sync::Mutex;

impl API {
/// Returns a list of available platforms.
Expand All @@ -22,7 +22,9 @@ impl API {
// This mutex is used to work around weak OpenCL implementations.
// On some implementations concurrent calls to clGetPlatformIDs
// will cause the implantation to return invalid status.
static mut platforms_mutex: StaticMutex = MUTEX_INIT;
lazy_static! {
static ref platforms_mutex: Mutex<()> = Mutex::new(());
}

let guard = unsafe {platforms_mutex.lock()};
try!(unsafe {API::ffi_get_platform_ids(0, ptr::null_mut(), (&mut num_platforms))});
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
#![cfg_attr(lint, feature(plugin))]
#![cfg_attr(lint, plugin(clippy))]
#![allow(dead_code)]
#![feature(static_mutex)]
#![deny(missing_docs,
missing_debug_implementations, missing_copy_implementations,
trivial_casts, trivial_numeric_casts,
Expand All @@ -145,6 +144,8 @@ extern crate libc;
extern crate bitflags;
#[macro_use]
extern crate enum_primitive;
#[macro_use]
extern crate lazy_static;
extern crate num;
extern crate byteorder;
extern crate rblas as blas;
Expand Down

0 comments on commit 6556934

Please sign in to comment.