pi4j-v2 icon indicating copy to clipboard operation
pi4j-v2 copied to clipboard

Extend the Context with an ExecutorService

Open FDelporte opened this issue 5 years ago • 2 comments

Different approaches should be possible

  • User can inject his own executor service into the Context
  • The Context needs to create its own ExecutorService if none is provided

This ExecutorService is needed for

  • DigitalOut Blink
  • DigitalOut Pulse

https://www.baeldung.com/java-executor-service-tutorial

FDelporte avatar Jun 12 '20 20:06 FDelporte

Multi-threaded capability and implementations of the asynchronous APIs would be a terrific step forward!

I assume this would require some non-trivial changes to provide the necessary thread safety, correct?

tcfurrer avatar Dec 12 '21 22:12 tcfurrer

Indeed @tcfurrer will have some impact. I have been looking into this in the past.

It would all start with defining the ExecutorService in the context https://github.com/Pi4J/pi4j-v2/blob/develop/pi4j-core/src/main/java/com/pi4j/context/Context.java

And could be used to handle for instance thread actions like pulsing a LED https://github.com/Pi4J/pi4j-v2/blob/develop/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalOutputBase.java#L102

These are only a few first steps and to be further investigated where and how such multi-threading should be applied.

Here would be an ideal place to discuss this functionality.

FDelporte avatar Dec 13 '21 06:12 FDelporte