mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 02:54:42 +00:00
Introducing RCTAssertUIManagerQueue()
Reviewed By: javache Differential Revision: D4868564 fbshipit-source-id: b9b9f6cf8f31495bb0e82fb60b2402dde460ddb8
This commit is contained in:
parent
bd004568d3
commit
2a984326b0
@ -85,13 +85,13 @@ typedef void (^RCTFatalHandler)(NSError *error);
|
||||
* Convenience macro for asserting that we're running on main queue.
|
||||
*/
|
||||
#define RCTAssertMainQueue() RCTAssert(RCTIsMainQueue(), \
|
||||
@"This function must be called on the main thread")
|
||||
@"This function must be called on the main queue")
|
||||
|
||||
/**
|
||||
* Convenience macro for asserting that we're running off the main queue.
|
||||
*/
|
||||
#define RCTAssertNotMainQueue() RCTAssert(!RCTIsMainQueue(), \
|
||||
@"This function must not be called on the main thread")
|
||||
@"This function must not be called on the main queue")
|
||||
|
||||
/**
|
||||
* Deprecated, do not use
|
||||
|
@ -25,6 +25,17 @@ RCT_EXTERN dispatch_queue_t RCTGetUIManagerQueue(void);
|
||||
*/
|
||||
RCT_EXTERN char *const RCTUIManagerQueueName;
|
||||
|
||||
/**
|
||||
* Check if we are currently on UIManager queue.
|
||||
*/
|
||||
RCT_EXTERN BOOL RCTIsUIManagerQueue(void);
|
||||
|
||||
/**
|
||||
* Convenience macro for asserting that we're running on UIManager queue.
|
||||
*/
|
||||
#define RCTAssertUIManagerQueue() RCTAssert(RCTIsUIManagerQueue(), \
|
||||
@"This function must be called on the UIManager queue")
|
||||
|
||||
/**
|
||||
* Posted right before re-render happens. This is a chance for views to invalidate their state so
|
||||
* next render cycle will pick up updated views and layout appropriately.
|
||||
|
@ -345,6 +345,16 @@ dispatch_queue_t RCTGetUIManagerQueue(void)
|
||||
return shadowQueue;
|
||||
}
|
||||
|
||||
BOOL RCTIsUIManagerQueue()
|
||||
{
|
||||
static void *queueKey = &queueKey;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
dispatch_queue_set_specific(RCTGetUIManagerQueue(), queueKey, queueKey, NULL);
|
||||
});
|
||||
return dispatch_get_specific(queueKey) == queueKey;
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
{
|
||||
return RCTGetUIManagerQueue();
|
||||
|
Loading…
x
Reference in New Issue
Block a user