1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! is_main_thread is a bare bones library to simply check if the current thread is the main
//! thread is the most platform independent way possible
//!
//! The initial code for these checks was taken from the [winit crate](https://crates.io/crates/winit)
//! collected here for the main purpose of allowing winit to be an optional dependency but
//! also have consistent behaviour should you allow another windowing library which might expect you
//! to use the main thread but either way doesn't enforce it like winit.
use platform;
extern crate objc;
/// The sole simple function, to check whether or not the calling thread is the main thread
///
/// If the current platform is not supported by this test the 'None' is returned,
/// else 'Some(bool)' is returned with the appropriate value
/// Of note, for the sanity test to succeed you must run cargo test
/// with the additional parameter '--test-threads=1' like:
/// 'cargo test -- --test-threads=1'