-
Notifications
You must be signed in to change notification settings - Fork 121
ndk-glue: Wrap NativeWindow/InputQueue locks in a newtype
#288
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
Conversation
|
CC @rib. |
|
Although I'm not a fan of the current design that requires explicit locking, this patch in itself looks good to me for helping avoid leaking implementation details. |
|
Something else to consider here is that Something I was just experimenting with, that's somewhat related to this, was a reference counting wrapper for NativeWindow like: And an API for querying the NativeWindow from a separate I was looking at remove the need to for any global/static API for accessing the In my case I'm also not concerned about locking the window a means to block Java from notifying the app about SurfaceView callbacks, so the reference it just about ensuring the pointer would remain valid. I understand that's not a concern here (since the lock is intended to block the code that might drop the reference and invalidate the pointer) but I figured it was worth mentioning here for future consideration. |
We discussed many times that this is something to be improved in the future, when implementing a unified API over
And the rest of your takes-5-minutes-to-read-wall-of-text becomes moot 😩 😫
#309...
We discussed this at length as well? |
As recently recommended/requested, this prevents `ndk_glue` from leaking its underlying lock implementation, and relieves downstream crates from having to import and specify the appropriate lock type. Especially in light of a scheduled migration to `parking_lot`. Note that this won't prevent against API breakage introduced by the intended change of transposing the `Option` inside this `LockReadGuard` as that can't be done prior to switching to `parking_lot`, and it'll be its own free-standing API ergonomics improvement regardless (`Option` now only needs to be unwrapped/checked once). Finally add some more doc-comments to link to the new lock and explain how the locks should be used on the `*Created` events and getter functions too, instead of describing it only on the `*Destroyed` events.
3483568 to
2ae10c3
Compare
As recently recommended/requested, this prevents
ndk_gluefrom leaking its underlying lock implementation, and relieves downstream crates from having to import and specify the appropriate lock type. Especially in light of a scheduled migration toparking_lot.Note that this won't prevent against API breakage introduced by the intended change of transposing the
Optioninside thisLockReadGuardas that can't be done prior to switching toparking_lot, and it'll be its own free-standing API ergonomics improvement regardless (Optionnow only needs to be unwrapped/checked once).Finally add some more doc-comments to link to the new lock and explain how the locks should be used on the
*Createdevents and getter functions too, instead of describing it only on the*Destroyedevents.