KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Execute async on self?

  • Execute async on self?

    Posted by calum_h on November 3, 2022 at 12:00 am

    Hi,

    I have a decision tree function and rather than run it recursively and building a stack I’d like to trigger the next execution asyncly. The idea is that when the process is idle it will handle then next  branch.

    The idea is to have something like this inside the function:

    neg[0i] “execute_next[]”

    I know neg[0i] doesn’t work but is there some internal command that can handle this?

    An alternative is to create a FIFO pipe, just curious if there’s a way to do this.

    calum_h replied 7 months, 1 week ago 2 Members · 2 Replies
  • 2 Replies
  • gyorokpeter-kx

    Member
    November 3, 2022 at 12:00 am

    Not directly, but the .z.ts callback can only run during idle time, and you can set it up such that it will run very soon after your function finishes. It is also possible to use a timer library such as this one that takes care of handling the callback and timeout, so you can set up a relative timer to run in zero milliseconds which has the effect of running your function during idle time.

  • calum_h

    Member
    November 30, 2022 at 12:00 am

    Hi thanks for this. In the end I handled it using converge with async jobs using a callback to trigger the parent jobs. The callback was either timer based or ipc based.

Log in to reply.