dugsq / xenograte-xct

Xenograte Community Toolkit (XCT)
Other
19 stars 5 forks source link

wiki should explain how loop-delay actually works #11

Open ghost opened 11 years ago

ghost commented 11 years ago

here: https://github.com/Nodally/xenograte-xct/wiki/xenode#nodebase-variables loop-delay 5 for example means, it will delay 5 seconds after process() finished executing, (unless xenode was just started then it's 5 seconds after startup()), that is: if process() takes 7 seconds to execute then after it finishes and +5 more seconds it will execute again. (tested)

dougsq commented 11 years ago

Yes I agree.

The loop_delay is used in an eventmachine timer to call the xenode's process() method. When a xenode first starts the EM timer is started and after the time has elapsed it will call process(). The process() and process_message() are blocking calls so if they are busy the eventmachine loop (and eventmachine timers) are blocked as well. You can use include EM::Deferrable to create an asynchronous xenode if you like. Em defferable info is here: http://eventmachine.rubyforge.org/docs/DEFERRABLES.html

ghost commented 11 years ago

Thanks for the info. For now I was trying to make sure it's not using the deferrable thing by default, and (not using) it is what I wanted, because I didn't want to find it executing process() while it was still inside process() from the last time and just build a tsunami like that

dougsq commented 11 years ago

Yes a xenode is purposely not a deferrable so it doesn't trip up developers.