Beh01der / EasyFlow

EasyFlow - Simple and lightweight Finite State Machine for Java
http://datasymphony.com.au/open-source/easyflow
Apache License 2.0
445 stars 86 forks source link

Please add Event.scheduledTrigger #4

Closed mrniko closed 11 years ago

mrniko commented 11 years ago

Thanks for this awesome and really lightweight engine!!!

But for my requirements i need to have a support of event triggering scheduling. I suggest to add a special method for this in Event class:

public void scheduledTrigger(final C context, long delay, TimeUnit unit) { scheduledExecutorService.schedule(new Runnable() { trigger(context); }, delay, unit); }

scheduledExecutorService - should be configurable like executor in EasyFlow object.

What do you think about such feature?

mrniko commented 11 years ago

I was wrong about this feature. I think it's up to developer to implement this.

Beh01der commented 11 years ago

Hi mrniko, Thanks for using EasyFlow and giving your feedback. This method cannot be added to Event class as, according to the current design, this sort of functionality (when and on which thread handlers are executed) should be implemented within Executors. Therefore, I can see 2 options to implement delay on event triggering:

  1. If you need it in many places in your State Machine, then you can implement your custom Executor that runs tasks with certain delay. If you need this delay to be variable, you can store delay value in Context and access it from your Executor.
  2. If you only need it in one or two places, just use timers outside EasyFlow.

Regards, Andrey

Beh01der commented 11 years ago

Hi Nikita, Thanks for using EasyFlow and giving your feedback. Please see my reply on GitHub.

Regards, Andrey

On 11 May 2013 18:55, Nikita Koksharov notifications@github.com wrote:

I was wrong about this feature. I think it's up to developer to implement this.

— Reply to this email directly or view it on GitHubhttps://github.com/Beh01der/EasyFlow/issues/4#issuecomment-17756591 .