On Wed, Dec 8, 2010 at 5:37 PM, Paul Merlin <[email protected]> wrote:
> To keep you informed, Qi4j Scheduler implementation is going well. I'm writing
> it externally before importing code in qi4j-librar...@develop so the code
> history will be simple.
Don't worry about history :-)
I'd rather see the code evolve in front of me, especially since I have
fairly immediate need of this too.
> For now the scheduler use cron expressions (extended to seconds) and support
> persistent and volatile schedules.
So, I create one Schedule per 'execution pattern', and then associate
Tasks with that Schedule?
If so, sounds reasonable, and in direct analogy of Timer and TimerTask.
> It use two entities, Schedule and Task. There is no directly usable TaskEntity
> for now but code is provided so that you can write your taks with something
> like:
>
> �...@mixins(FooTaskMixin.class)
> interface FooTaskEntity extends Task, EntityComposite {}
>
> class FooTaskMixin implements TaskBehavior { void run() {...} }
Should Task and TaskBehavior match? Or is TaskBehavior a superclass of Task?
> The SchedulerService use a pulse-thread with a configurable rhythm that
> enqueue
> tasks in a thread pool (size is configurable too).
A common technique I used way back in the past, where the Scheduler
and Timers were actually the same thing, was to 'know' the 'nextTime'
for each Task, instead of recalcing the schedule every second. This
might be not relevant in these days and times, and that your 'tick
frequency' is fairly long (second(s) I would guess), and I supported
from 10ms to years in the same scheduler.
> As the Task is an entity, it's run() method is run in a UoW. When thinking
> about
> tasks that need to run code in several subsequents UoW (ie. for batching
> purpose) I thought about chaining tasks but it feels a little bit hackish.
> Could
> a Task pause the current UoW (which is handling Task state), handle "nested"
> UoWs and then resume the said UoW ?
One way could be to have a "executeOnce(Task task, boolean
afterCurrentSuccessful)" method on the schedule service, which Tasks
could then post things to be executed either after the current UoW has
been successfully completed, or 'any time' if it doesn't matter as
long as it happens separately.
Once again, I think code in front of me would help a lot with more suggestions.
Cheers
--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java
I live here; http://tinyurl.com/2qq9er
I work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev