|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
periodic task libraryHi,
I had the occasion to need periodic tasks for a project I'm working on, and came up with a generic a4d.tasks library. Here is the current design: create(inMethodToExecute; inPeriodInMinutes {; inData {; inLimit}}) -> longint - inMethodToExecute must be a globally accessible Active4D library method with the following signature: method "myTask"($inId; $inAction; $ioData) - inId is the task id - inAction is "init", "exec", or "deinit" - ioData is the data that was passed into 'create task' - you may call 'delete($inId)' within this method to cause the task to be deleted on the next run - inPeriodInMinutes is how long between calls, >= 1. No guarantee the task will be run that often, it is actually the minimum number of minutes between calls, since the queue is only checked every 10 seconds - inData if passed and non-zero must be a *global* collection, it will be cleared with 'deep clear collection' when the task is deleted - inLimit if passed is the number of times you want the task to be executed, after which it will be removed, < 0 means unlimited delete(inId) - remove the task and deep clear its data - if called from a currently running task, marks it for deletion on the next run dump - Dumps the task list to the A4D console I would like any comments or suggestions before I release it as part of the Active4D standard libs. The task runner will be a 4D method running in a separate process that calls a4d.tasks.execute every 10 seconds. Typically in one of your libraries, you would do something like this: method "__load__" self{"mytask"} := a4d.tasks.create("mylib.mytaskHandler"; 1) end method method "__unload__" ad4.tasks.delete(self{"mytask"}) end method method "mytaskHandler"($id; $action; $data) case of :($action = "init") // do some init :($action = "exec") // run my task :($action = "deinit") // cleanup end case end method Kind regards, Aparajita www.aparajitaworld.com "If you dare to fail, you are bound to succeed." - Sri Chinmoy | www.srichinmoy.org _______________________________________________ Active4D-dev mailing list Active4D-dev@... http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/ |
|
|
Re: periodic task libraryThanks Aparajita,
I'm back to working with A4D next week so will have a look at this. Sounds like a great feature... Regards, Michael. On 24 Oct 2009, at 21:47, Aparajita Fishman wrote: > Hi, > > I had the occasion to need periodic tasks for a project I'm working > on, and came up with a generic a4d.tasks library. Here is the > current design: > > create(inMethodToExecute; inPeriodInMinutes {; inData {; inLimit}}) - > > longint > - inMethodToExecute must be a globally accessible Active4D library > method with the following signature: > > method "myTask"($inId; $inAction; $ioData) > - inId is the task id > - inAction is "init", "exec", or "deinit" > - ioData is the data that was passed into 'create task' > - you may call 'delete($inId)' within this method to cause the task > to be deleted on the next run > > - inPeriodInMinutes is how long between calls, >= 1. No guarantee > the task will be run that often, it is actually the minimum number > of minutes between calls, since the queue is only checked every 10 > seconds > - inData if passed and non-zero must be a *global* collection, it > will be cleared with 'deep clear collection' when the task is deleted > - inLimit if passed is the number of times you want the task to be > executed, after which it will be removed, < 0 means unlimited > > delete(inId) > - remove the task and deep clear its data > - if called from a currently running task, marks it for deletion on > the next run > > dump > - Dumps the task list to the A4D console > > > I would like any comments or suggestions before I release it as part > of the Active4D standard libs. The task runner will be a 4D method > running in a separate process that calls a4d.tasks.execute every 10 > seconds. > > Typically in one of your libraries, you would do something like this: > > method "__load__" > self{"mytask"} := a4d.tasks.create("mylib.mytaskHandler"; 1) > end method > > method "__unload__" > ad4.tasks.delete(self{"mytask"}) > end method > > method "mytaskHandler"($id; $action; $data) > case of > :($action = "init") > // do some init > > :($action = "exec") > // run my task > > :($action = "deinit") > // cleanup > end case > end method > > > Kind regards, > > Aparajita > www.aparajitaworld.com > > "If you dare to fail, you are bound to succeed." > - Sri Chinmoy | www.srichinmoy.org > > _______________________________________________ > Active4D-dev mailing list > Active4D-dev@... > http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev > Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/ _______________________________________________ Active4D-dev mailing list Active4D-dev@... http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/ |
|
|
Re: periodic task libraryOn Oct 24, 2009, at 3:47 PM, Aparajita Fishman wrote: > I would like any comments or suggestions before I release it as part > of the Active4D standard libs. The task runner will be a 4D method > running in a separate process that calls a4d.tasks.execute every 10 > seconds. I assume this process is running on the machine running Active4D. We created a cron task in 4D that could call Active4D code. Can't remember all the details, but our missing logic was that the cron task was running on the server and Active4D was running on a 4d client (no Active4D or web license on the server). Since we needed it for both 4D and Active4D, we just gave up the Active4D side (guess we could have used execute on client - but I'm not a 4D person). For the Active4D stuff, we just created a cron task in Mac OS that would generate a curl to a controller script. Your library approach would probably simplify that process. Steve Alex _______________________________________________ Active4D-dev mailing list Active4D-dev@... http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/ |
|
|
Re: periodic task library> I assume this process is running on the machine running Active4D.
Yes, it only runs on that machine if Active4D is running on the machine. Kind regards, Aparajita www.aparajitaworld.com "If you dare to fail, you are bound to succeed." - Sri Chinmoy | www.srichinmoy.org _______________________________________________ Active4D-dev mailing list Active4D-dev@... http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/ |
| Free embeddable forum powered by Nabble | Forum Help |