Skip to content
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

x/mobile/exp/sensor: simplify os thread proxifying mechanism on Android #12462

Open
rakyll opened this issue Sep 3, 2015 · 0 comments
Open
Labels
mobile Android, iOS, and x/mobile
Milestone

Comments

@rakyll
Copy link
Contributor

rakyll commented Sep 3, 2015

The Android implementation of the sensor package need to initialize a ALooper. ALoopers must be accessed from the same OS thread, therefore each operation on the package must be done on a goroutine that is locked to an OS thread.

The current mechanism accepts new messages through a signal channel depending on the signals type, invokes the required functions and sets the return values. It requires each function call to be represented with a different input signal.

This mechanism could be simplified by making the locked goroutine consuming a chan of functions.

type inOut func(done chan struct{})

m.inOut <- func(done chan struct{}) {
    // do something on the locked goroutine
    // when done, close done.
    close(done) 
}
@rakyll rakyll self-assigned this Sep 3, 2015
@rakyll rakyll added this to the Unreleased milestone Sep 3, 2015
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jul 20, 2017
@rsc rsc unassigned rakyll Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

2 participants