Skip to content

Remove busy loop from rx_thread#18

Closed
trivialkettle wants to merge 1 commit intofishpepper:masterfrom
trivialkettle:patch-1
Closed

Remove busy loop from rx_thread#18
trivialkettle wants to merge 1 commit intofishpepper:masterfrom
trivialkettle:patch-1

Conversation

@trivialkettle
Copy link
Copy Markdown

The rx_thread executed a busy loop and loaded a single core to 100%. This change reduces the load significantly.

There would also be another solution by using

        """ process data as long as requested """
        while self.rx_thread_state == USBtin.RX_THREAD_RUNNING:
            buf = self.serial_port.read(max(1, self.serial_port.inWaiting()))
            if buf:
# ...

This read blocks until 1 or inWaiting() bytes are available. Additionally one need to update stop_rx_thread() by adding

        self.serial_port.cancel_read()

to cancel the blocking read.

The rx_thread executed a busy loop and loaded a single core to 100%. This change reduces the load significantly.
@trivialkettle
Copy link
Copy Markdown
Author

I created a pull request with my other proposed changes in #19 after testing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant