wizard97 / ArduinoProcessScheduler

An Arduino object oriented process scheduler designed to replace them all
46 stars 16 forks source link

Added sub-instancing example. #15

Open GitMoDu opened 6 years ago

GitMoDu commented 6 years ago

Discussion here: https://github.com/wizard97/ArduinoProcessScheduler/issues/14

wizard97 commented 6 years ago

Appreciate you following through and making an example.

Looks mostly good, a few suggestions:

GitMoDu commented 6 years ago
  1. Sure, it is confusing. I think I started by extending the Process class but then realized it might be more useful to have an example without direct inheritance.

  2. Didn't catch that part, I'll add it.

wizard97 commented 6 years ago

I think it would actually be pretty cool if you could think of an example where this "managing process" is actually a process itself. Maybe you make the manager process change the way the LEDS blink every 10 seconds or something? That would be pretty cool.

GitMoDu commented 6 years ago

Can you add a deconstructor to the BlinkerManager that deletes all the BlinkProcesses from the scheduler?

Do you mean just overriding the cleanUp() method, or catching the ~Process() to remove the sub-processes from the scheduler?

wizard97 commented 6 years ago

Definitely needs to be caught in cleanUp().

I actually realized calling cleanUp() on the child procs in the deconstructor isn't safe. As calling cleanUp() only queues the request to destroy a process. By the time the request actually gets processed the childprocs themselves will be out of scope since the deconstructor already would have run.

GitMoDu commented 6 years ago

Updated with clean-up.

wizard97 commented 6 years ago

Sorry, I completely missed your updates!

Everything looks good, besides the cleanup of the child processes. I can't think of a way to do it that is clean and also safe.