forked from NASAWorldWind/WorldWindJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreadSupport.m
More file actions
53 lines (43 loc) · 1.19 KB
/
ThreadSupport.m
File metadata and controls
53 lines (43 loc) · 1.19 KB
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
46
47
48
49
50
51
52
53
/*
* Copyright (C) 2014 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
#import "ThreadSupport.h"
/*
Version $Id: ThreadSupport.m 1948 2014-04-19 20:02:38Z dcollins $
*/
/* The singleton ThreadSupport instance. Created in ThreadSupport's static initializer.*/
static ThreadSupport *sharedInstance;
@implementation ThreadSupport
+ (ThreadSupport *)sharedInstance
{
return sharedInstance;
}
/*
Initializes the ThreadSupport's shared singleton instance. Called exactly once just before ThreadSupport receives
its first message. May also be called explicitly, or by a subclass that overrides this message.
*/
+ (void)initialize
{
static BOOL initialized = NO;
if (!initialized)
{
initialized = YES;
sharedInstance = [[ThreadSupport alloc] init];
}
}
- (void)performBlockOnMainThread:(void(^)(void))block
{
if (block == NULL)
{
return;
}
[self performSelectorOnMainThread:@selector(doPerformBlock:) withObject:Block_copy(block) waitUntilDone:NO];
}
- (void)doPerformBlock:(void(^)(void))block
{
block();
Block_release(block);
}
@end