File tree Expand file tree Collapse file tree 1 file changed +1
-34
lines changed Expand file tree Collapse file tree 1 file changed +1
-34
lines changed Original file line number Diff line number Diff line change 1
1
// Take a look at the license at the top of the repository in the LICENSE file.
2
2
3
- use std:: cell:: Cell ;
4
- use std:: sync:: atomic:: { AtomicBool , Ordering } ;
5
-
6
- thread_local ! {
7
- static IS_MAIN_THREAD : Cell <bool > = Cell :: new( false )
8
- }
9
-
10
- static INITIALIZED : AtomicBool = AtomicBool :: new ( false ) ;
11
-
12
3
macro_rules! assert_initialized_main_thread {
13
- ( ) => {
14
- #[ allow( unknown_lints) ]
15
- #[ allow( clippy:: if_then_panic) ]
16
- if !crate :: rt:: is_initialized_main_thread( ) {
17
- if crate :: rt:: is_initialized( ) {
18
- panic!( "GDK may only be used from the main thread." ) ;
19
- } else {
20
- panic!( "GDK has not been initialized. Call `gtk::init` first." ) ;
21
- }
22
- }
23
- } ;
4
+ ( ) => { } ;
24
5
}
25
6
26
7
/// No-op.
27
8
macro_rules! skip_assert_initialized {
28
9
( ) => { } ;
29
10
}
30
-
31
- /// Returns `true` if GDK has been initialized.
32
- #[ inline]
33
- pub fn is_initialized ( ) -> bool {
34
- skip_assert_initialized ! ( ) ;
35
- INITIALIZED . load ( Ordering :: Acquire )
36
- }
37
-
38
- /// Returns `true` if GDK has been initialized and this is the main thread.
39
- #[ inline]
40
- pub fn is_initialized_main_thread ( ) -> bool {
41
- skip_assert_initialized ! ( ) ;
42
- IS_MAIN_THREAD . with ( |c| c. get ( ) )
43
- }
You can’t perform that action at this time.
0 commit comments