-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async RPC call of Android Binder #1201
Merged
Merged
Conversation
This file contains 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
经测试改了之后大幅度加速了 |
Him188
reviewed
Nov 15, 2024
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
Him188
reviewed
Nov 16, 2024
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteCall.kt
Outdated
Show resolved
Hide resolved
Him188
reviewed
Nov 16, 2024
app/shared/app-data/src/androidMain/kotlin/domain/torrent/service/AniTorrentService.kt
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteTorrentSession.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteTorrentSession.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/service/proxy/TorrentSessionProxy.kt
Outdated
Show resolved
Hide resolved
app/shared/app-data/src/androidMain/kotlin/domain/torrent/service/proxy/TorrentSessionProxy.kt
Outdated
Show resolved
Hide resolved
Him188
reviewed
Nov 16, 2024
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.
RemoteCall
改名叫 RemoteObject
是不是更好一点
remoteObject.callSuspend { foo() }
听起来更合理.
class RemoteTorrentSession(private val aidl: RemoteObject<IRemoteTorrentSession>)
…RemoteContinuation`
Him188
requested changes
Nov 16, 2024
app/shared/app-data/src/androidMain/kotlin/domain/torrent/client/RemoteObject.kt
Outdated
Show resolved
Hide resolved
Him188
approved these changes
Nov 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
此 PR 旨在消除 service proxy 的
runBlocking
,提高 service 吞吐量目前问题
例如,
IRemoteTorrentDownloader.aidl
中的startRemoteDownload
接口为这个接口对应了
TorrentDownloader
的startDownload
函数,是一个 suspend 函数目前在 client 的调用实现为
在 service 的实现为
client 调用
startRemoteDownload
时需要等待 service 实现中的runBlocking
执行完成才会返回结果,如果runBlocking
执行了很长时间,那 client 调用端会一直等待结果而阻塞,service 实现也会因为runBlocking
而不能使用当前的 binder 线程继续处理其他 client 调用新变化
此 PR 将
startRemoteDownload
AIDL 接口改为如下回调形式其中,
IDisposableHandle
用于处理 service 取消协程的动作,client 取消协程后通过IDisposableHandle
通知 service 同样取消对应处理协程,RemoteContinuation
用于回调结果如此而来,client 通过
suspendCancellableCoroutine
就可以比较轻易地实现回调 API 的挂起service 也可以去除
runBlocking
,并且快速返回结果