fftw3 0.0.2

Bindings to FFTW3: the Fastest Fourier Transform in the West. This library aims to expose the full power of FFTW3 in high-performance, safe and idiomatic manner. NB. FFTW3 is licensed GPLv2 (or later) by default, and so applications using it must be distributed under those terms (the license of these bindings is independent).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Some functions in FFTW are not thread-safe, and one should ensure
//! that only one thread is executing these at a time. This module
//! provides a lock for this purpose.

use std::sync::{StaticMutex, MUTEX_INIT};

/// Hold this lock when doing anything thread-unsafe with FFTW.
pub static LOCK: StaticMutex = MUTEX_INIT;

/// Run the given closure inside the critical section of the FFTW
/// lock.
pub fn run<A, F: FnOnce() -> A>(f: F) -> A {
    let _g = LOCK.lock();
    f()
}