-
Notifications
You must be signed in to change notification settings - Fork 6k
Introduce task_runner_checker, task_runner_weak_ptr #17649
Conversation
fml/memory/task_runner_checker.h
Outdated
| } | ||
|
|
||
| private: | ||
| TaskQueueId self_; |
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.
I think self_ is an ambiguous name. Can this be called, initialized_queue_id_?
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.
done
fml/memory/task_runner_checker.h
Outdated
| ~TaskRunnerChecker() = default; | ||
|
|
||
| bool RunsOnCreationTaskRunner() const { | ||
| FML_DCHECK(fml::MessageLoop::IsInitializedForCurrentThread()); |
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.
I think this can be a FML_CHECK.
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.
makes sense, done!
fml/memory/task_runner_checker.h
Outdated
| auto queues = MessageLoopTaskQueues::GetInstance(); | ||
| if (queues->Owns(current_queue_id, self_)) { | ||
| return true; | ||
| } | ||
| if (queues->Owns(self_, current_queue_id)) { | ||
| return true; | ||
| } |
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.
Can you refactor to share code with TaskRunner::RunsTasksOnCurrentThread?
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.
offline discussion, we will create a TaskRunnerWeakPtr to support the task runner checker
| } | ||
| }; | ||
|
|
||
| #if !defined(NDEBUG) |
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.
shouldn't this condition be flipped? As it stands it looks like these checks will only be run when NDEBUG is not specified. I think we should rely on FLUTTER_RUNTIME_MODE macro instead and run it on DEBUG builds.
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 how the current Thread_Runner works. I'm not sure if we should change the behavior in this PR? Maybe we can do it in a separate PR to be more explicit after landing this?
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
1 similar comment
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
f109ddf to
145c604
Compare
|
@googlebot I fixed it. |
145c604 to
21c0bf6
Compare
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
1 similar comment
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
iskakaushik
left a comment
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.
LGTM
fml/memory/task_runner_checker.h
Outdated
| } | ||
|
|
||
| private: | ||
| TaskQueueId self_; |
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.
done
| } | ||
| }; | ||
|
|
||
| #if !defined(NDEBUG) |
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 how the current Thread_Runner works. I'm not sure if we should change the behavior in this PR? Maybe we can do it in a separate PR to be more explicit after landing this?
fml/memory/task_runner_checker.h
Outdated
| ~TaskRunnerChecker() = default; | ||
|
|
||
| bool RunsOnCreationTaskRunner() const { | ||
| FML_DCHECK(fml::MessageLoop::IsInitializedForCurrentThread()); |
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.
makes sense, done!
fml/memory/task_runner_checker.h
Outdated
| auto queues = MessageLoopTaskQueues::GetInstance(); | ||
| if (queues->Owns(current_queue_id, self_)) { | ||
| return true; | ||
| } | ||
| if (queues->Owns(self_, current_queue_id)) { | ||
| return true; | ||
| } |
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.
offline discussion, we will create a TaskRunnerWeakPtr to support the task runner checker
|
|
||
| // Copy constructor. | ||
| WeakPtr(const WeakPtr<T>& r) = default; | ||
| explicit WeakPtr(const WeakPtr<T>& r) = default; |
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.
@iskakaushik Changed after your last approval:
I found implicit casting could be problematic as someone could want a TaskRunnerAffineWeakPtr but end up getting a WeakPtr.
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.
LGTM
| fml::WeakPtr<Engine> weak_engine_; // to be shared across threads | ||
| fml::WeakPtr<Rasterizer> weak_rasterizer_; // to be shared across threads | ||
| fml::WeakPtr<Engine> weak_engine_; // to be shared across threads | ||
| fml::TaskRunnerAffineWeakPtr<Rasterizer> |
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.
@iskakaushik Changed after your last approval:
It was implicitly casted from a TaskRunnerAffineWeakPtr to a WeakPtr
Replace thread_checker with task_runner_checker, make the weakPtr to be accessed from different threads as long as they are on the same task_runner (thread merging)
flutter/flutter#52253