Skip to content

Commit 32a16c9

Browse files
authored
Add note about AIDL methods taking &self (#2641)
1 parent 5f6b933 commit 32a16c9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/android/aidl/example-service/service.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ _birthday_service/Android.bp_:
2323

2424
- Point out the path to the generated `IBirthdayService` trait, and explain why
2525
each of the segments is necessary.
26+
- Note that `wishHappyBirthday` and other AIDL IPC methods take `&self` (instead
27+
of `&mut self`).
28+
- This is necessary because binder responds to incoming requests on a thread
29+
pool, allowing for multiple requests to be processed in parallel. This
30+
requires that the service methods only get a shared reference to `self`.
31+
- Any state that needs to be modified by the service will have to be put in
32+
something like a `Mutex` to allow for safe mutation.
33+
- The correct approach for managing service state depends heavily on the
34+
details of your service.
2635
- TODO: What does the `binder::Interface` trait do? Are there methods to
2736
override? Where source?
2837

0 commit comments

Comments
 (0)