Flutter Engine
The Flutter Engine
|
#import <FlutterThreadSynchronizer.h>
Instance Methods | |
(nullable instancetype) | - init |
(void) | - beginResizeForView:size:notify: |
(void) | - performCommitForView:size:notify: |
(void) | - performOnPlatformThread: |
(void) | - registerView: |
(void) | - deregisterView: |
(void) | - shutdown |
(instancetype) | - initWithMainQueue: [implementation] |
(BOOL) | - allViewsHaveFrame [implementation] |
(BOOL) | - someViewsHaveFrame [implementation] |
(void) | - drain [implementation] |
(void) | - blockUntilFrameAvailable [implementation] |
(BOOL) | - isWaitingWhenMutexIsAvailable [implementation] |
Protected Attributes | |
dispatch_queue_t | _mainQueue |
std::mutex | _mutex |
BOOL | _shuttingDown |
std::unordered_map< int64_t, CGSize > | _contentSizes |
std::vector< dispatch_block_t > | _scheduledBlocks |
BOOL | _beginResizeWaiting |
std::condition_variable | _condBlockBeginResize |
Takes care of synchronization between raster and platform thread.
All methods of this class must be called from the platform thread, except for performCommitForView:size:notify:.
Definition at line 18 of file FlutterThreadSynchronizer.h.
|
implementation |
Returns true if all existing views have a non-zero size.
If there are no views, still returns true.
Definition at line 26 of file FlutterThreadSynchronizer.mm.
- (void) beginResizeForView: | (FlutterViewIdentifier) | viewIdentifier | |
size: | (CGSize) | size | |
notify: | (nonnull dispatch_block_t) | notify | |
Blocks until all views have a commit with their given sizes (or empty) is requested.
Definition at line 26 of file FlutterThreadSynchronizer.mm.
|
implementation |
Blocks current thread until there is frame available. Used in FlutterEngineTest.
Provided by category FlutterThreadSynchronizer(TestUtils).
Definition at line 26 of file FlutterThreadSynchronizer.mm.
- (void) deregisterView: | (FlutterViewIdentifier) | viewIdentifier |
Requests the synchronizer to no longer track a view.
It is typically done when the view controller is destroyed.
Definition at line 26 of file FlutterThreadSynchronizer.mm.
|
implementation |
Definition at line 26 of file FlutterThreadSynchronizer.mm.
- (instancetype) init |
Creates a FlutterThreadSynchronizer that uses the OS main thread as the platform thread.
Definition at line 26 of file FlutterThreadSynchronizer.mm.
|
implementation |
Provided by category FlutterThreadSynchronizer(TestUtils).
Definition at line 26 of file FlutterThreadSynchronizer.mm.
|
implementation |
Blocks current thread until the mutex is available, then return whether the synchronizer is waiting for a correct commit during resizing.
After calling an operation of the thread synchronizer, call this method, and when it returns, the thread synchronizer can be at one of the following 3 states:
By eliminating the 1st case (such as using the notify callback), we can use this return value to decide whether the synchronizer is in case 2 or case 3, that is whether the resizing is blocked by a mismatching commit.
Provided by category FlutterThreadSynchronizer(TestUtils).
Definition at line 26 of file FlutterThreadSynchronizer.mm.
- (void) performCommitForView: | (FlutterViewIdentifier) | viewIdentifier | |
size: | (CGSize) | size | |
notify: | (nonnull dispatch_block_t) | notify | |
Called from raster thread. Schedules the given block on platform thread and blocks until it is performed.
If platform thread is blocked in beginResize:
for given size (or size is empty), unblocks platform thread.
The notify block is guaranteed to be called within a core animation transaction.
Definition at line 26 of file FlutterThreadSynchronizer.mm.
- (void) performOnPlatformThread: | (nonnull dispatch_block_t) | block |
Schedules the given block to be performed on the platform thread. The block will be performed even if the platform thread is blocked waiting for a commit.
Definition at line 26 of file FlutterThreadSynchronizer.mm.
- (void) registerView: | (FlutterViewIdentifier) | viewIdentifier |
Requests the synchronizer to track another view.
A view must be registered before calling begineResizeForView: or performCommitForView:. It is typically done when the view controller is created.
Definition at line 26 of file FlutterThreadSynchronizer.mm.
- (void) shutdown |
Called when the engine shuts down.
Prevents any further synchronization and no longer blocks any threads.
Definition at line 26 of file FlutterThreadSynchronizer.mm.
|
implementation |
Returns true if there are any views that have a non-zero size.
If there are no views, returns false.
Definition at line 26 of file FlutterThreadSynchronizer.mm.
|
protected |
Definition at line 23 of file FlutterThreadSynchronizer.mm.
|
protected |
Definition at line 26 of file FlutterThreadSynchronizer.mm.
|
protected |
Definition at line 20 of file FlutterThreadSynchronizer.mm.
|
protected |
Definition at line 17 of file FlutterThreadSynchronizer.mm.
|
protected |
Definition at line 18 of file FlutterThreadSynchronizer.mm.
|
protected |
Definition at line 21 of file FlutterThreadSynchronizer.mm.
|
protected |
Definition at line 19 of file FlutterThreadSynchronizer.mm.