This repository was archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Convert DefaultFileSource and dependents to actor model #7678
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bc12638
[core] add support for naming thread pool threads and setting them to…
kkaefer a5e284d
[android] remove unused code
kkaefer d90998c
[core] require a Scheduler (=ThreadPool) for DefaultFileSource constr…
kkaefer a720cd6
[core] move default AssetFileSource to use actors
kkaefer 69b188d
[core] also conver Android's AssetFileSource to the actor model
kkaefer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #pragma once | ||
|
|
||
| #include <mbgl/util/default_thread_pool.hpp> | ||
|
|
||
| namespace mbgl { | ||
| namespace android { | ||
|
|
||
| // May only be called from the main/UI thread. | ||
| inline ThreadPool& sharedThreadPool() { | ||
| static ThreadPool threadPool{ 4, { "Worker" } }; | ||
| return threadPool; | ||
| } | ||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #import "MGLThreadPool_Private.h" | ||
|
|
||
| #import "NSProcessInfo+MGLAdditions.h" | ||
|
|
||
| @interface MGLThreadPool () | ||
|
|
||
| @property (nonatomic) mbgl::ThreadPool *mbglThreadPool; | ||
|
|
||
| @end | ||
|
|
||
| @implementation MGLThreadPool | ||
|
|
||
| #pragma mark - Internal | ||
|
|
||
| + (instancetype)sharedPool { | ||
| if (NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) { | ||
| return nil; | ||
| } | ||
| static dispatch_once_t onceToken; | ||
| static MGLThreadPool *sharedThreadPool; | ||
| dispatch_once(&onceToken, ^{ | ||
| sharedThreadPool = [[self alloc] init]; | ||
| }); | ||
| return sharedThreadPool; | ||
| } | ||
|
|
||
| - (instancetype)init { | ||
| if (self = [super init]) { | ||
| _mbglThreadPool = new mbgl::ThreadPool(4, { "Worker" }); | ||
| } | ||
| return self; | ||
| } | ||
|
|
||
| - (void)dealloc { | ||
| delete _mbglThreadPool; | ||
| _mbglThreadPool = nullptr; | ||
| } | ||
|
|
||
| @end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #include <mbgl/util/default_thread_pool.hpp> | ||
|
|
||
| @interface MGLThreadPool : NSObject | ||
| @end | ||
|
|
||
| @interface MGLThreadPool (Private) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for a class extension, since the whole header is already internal to the project. A class extension would need to go in a separate header from the public header anyways.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks; as per the comment above, I'm planning on removing |
||
|
|
||
| /// Returns the shared instance of the `MGLThreadPool` class. | ||
| + (instancetype)sharedPool; | ||
|
|
||
| /** | ||
| The shared thread pool object owned by the shared thread pool object. | ||
| */ | ||
| @property (nonatomic) mbgl::ThreadPool *mbglThreadPool; | ||
|
|
||
| @end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary, since there won't be an offline storage object if we're rendering for IB, and even if we were, spinning up this thread pool should be cheap. The reason we do this in MGLOfflineStorage and MGLAccountManager is to avoid potentially expensive operations that may block MGLMapView from rendering within the allotted time.