ivanseidel / ArduinoThread

⏳ A simple way to run Threads on Arduino
MIT License
955 stars 196 forks source link

Static thread controller #13

Closed CAHEK7 closed 8 years ago

CAHEK7 commented 8 years ago

This is suggested solution for #6.

ivanseidel commented 8 years ago

Nice work! Thanks for contributing. One additional thing I would love, is to have an example of use of a StaticThreadController. Can you thing in something easy, that "improves" and shows a use case for it?

Thanks

CAHEK7 commented 8 years ago

Thanks for feedback, seems like I should revise my initial idea and do some adjustments in the code. As about improvements - Static version is a bit more efficient since it doesn't contain "empty" entries and shouldn't iterate over them. Also it doesn't have any size limitations except available memory. As about use case - everywhere if you don't need dynamically add or remove threads.

CAHEK7 commented 8 years ago

Static version is more efficient even if it holds 15 threads, because it "adds" threads to the array at compile time. It may save about 200-300 byte of memory. Just replaced Threads with Thread* and did the measurements.

ivanseidel commented 8 years ago

Thank you very much @CAHEK7! Just published the version. https://github.com/ivanseidel/ArduinoThread/releases/tag/2.1.0

Bumped from 2.0.3 to 2.1.0 as it includes new features.