Skip to content

De-jankify select() call #4

Description

@brian-armstrong

The merging of posix-style select() call with Go seems pretty jank, at least in this implementation. The select() has a 1-second timeout, so that if there are no pins changing, it takes up to a second to add and remove new pins to the watcher https://github.com/brian-armstrong/gpio/blob/master/watcher.go#L112 and https://github.com/brian-armstrong/gpio/blob/master/watcher.go#L193

We should investigate if it's possible to remove these in some way without impacting CPU.

One possible option, though sort of gross, would be to open a file in /tmp (or a socket) and have our select() call include it in its readfds. Then a goroutine could write to this file descriptor in order to wake up the select() caller, which could then do maintenance like adding/removing pins or closing. If we did this, we could possibly remove the 1-second timeout entirely, allowing us to sleep more while having very good latency for these sorts of operations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions