multiple timers in a single q process

Hi ExpertsI have a case where i want to do specific calculations at specificintervals.like there are three functions func1,func2 and func3.Every 1 minute i want to run func1Every 2 minutes 30 seconds I want to run func2.and Every 45 seconds i want to run func3All 3 functions in the same q process.Can this be achieved ?regardsAlex

You can have only one timer. So you can set it to 15 seconds and use
.z.ts function similar to the one below (it uses global counter value
to check which functions should be evaluated):
.z.ts:{
f:(f1;f2;f3); // functions f1, f2, f3
i+::1; // global counter
@[;()] each f[where not i mod 4 10 3]; // find functions to be evaluated
};

Kamil.

The way it’s usually done is by multiplexing the timer. i.e. A table
of timings is kept and a function to call. So you’d have something
like this:

\d .timer
funcs:(function:`$();time:“i”$();params:();lastcall:“z”$())
add:{[f;t;p]}
del:{[f]}
call:{}
\d .
.z.ts:{call x}
\t 10

I can reply with the filled in code later when I have time and I’m
more awake ;-)

Doing anything like this in kdb isn’t perfect because of the way .z.ts
works and the fact that some CPU is consumed to give it a lower
resolution. If I recall correctly, it fires off \t milliseconds after
the last execution of .z.ts. This means that if you call a function
from .z.ts and it takes longer than \t milliseconds then it will fire
off the next call immediately.

You could also consider using async functions in other q processes to
execute the same way unless you needed all data local.