Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@hellohuanlin
Copy link
Contributor

@hellohuanlin hellohuanlin commented Mar 2, 2022

Removes QueueHelper class and use function instead.

Also renamed file to QueueUtils to be consistent with CameraTestUtils

List which issues are fixed by this PR. You must list at least one issue.

NA

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

No version change: just minor code cleanup.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@hellohuanlin hellohuanlin force-pushed the camera_remove_queue_helper_class branch from af203f4 to 20d5fa6 Compare March 2, 2022 22:52
@hellohuanlin hellohuanlin marked this pull request as ready for review March 2, 2022 23:01
@hellohuanlin hellohuanlin changed the title [camera]remove QueueHelper class and directly use functions [camera]remove QueueHelper class Mar 3, 2022
@hellohuanlin hellohuanlin requested a review from jmagman March 3, 2022 21:12
- (void)setStreamHandler:(NSObject<FlutterStreamHandler> *)handler
completion:(void (^)(void))completion {
FLTEnsureToRunOnMainQueue(^{
dispatch_block_t block = ^{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see why you found this pattern tedious, Objective-C needs so much boilerplate to do something trivial:

if (!NSThread.isMainThread) {
  [NSOperationQueue.mainQueue addOperationWithBlock:^{
    [self setStreamHandler:handler completion:completion];
  }];
  return;
}

[self.channel setStreamHandler:handler];
completion();

or

void (^block)(void)  = ^{ // or typedef 
  [self.channel setStreamHandler:handler];
  completion();
};
if (NSThread.isMainThread) {
  block();
} else {
  [NSOperationQueue.mainQueue addOperationWithBlock:block];
}

I guess the utility function was better... 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted to the original commit

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the motivation to do this? I thought the existing code was cleaner?

@hellohuanlin hellohuanlin force-pushed the camera_remove_queue_helper_class branch from e2b4157 to 20d5fa6 Compare March 4, 2022 21:57
@hellohuanlin hellohuanlin requested review from cyanglaz and jmagman March 4, 2022 21:58
@hellohuanlin
Copy link
Contributor Author

What was the motivation to do this? I thought the existing code was cleaner?

@cyanglaz I changed from objc static method to C functions and then @jmagman recommended to remove this helper but it didn't turn out as good, so i just reverted it back.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


/// A class that contains dispatch queue related helper functions.
@interface QueueHelper : NSObject
extern const char* FLTCaptureSessionQueueSpecific;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: Is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. This is used to verify if an operation is on capture session queue.

@hellohuanlin hellohuanlin added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Mar 7, 2022
@fluttergithubbot fluttergithubbot merged commit b906ea5 into flutter:main Mar 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

p: camera platform-ios waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants